Code:
#include <windows.h>
static char gszClassName[] = "MyWindowClass";
static HINSTANCE ghInstance = NULL;
HWND hBorder,hBox1,hBox2,hEqual,hBox3;
LRESULT CALLBACK WndProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
{
HDC hdc;
PAINTSTRUCT ps;
LPSTR szMessage = "text_test";
switch(Message)
{
case WM_PAINT:
{
hdc = BeginPaint(hwnd, &ps);
TextOut(hdc, 70, 40, szMessage, strlen(szMessage));
EndPaint(hwnd, &ps);
}
break;
case WM_CREATE:
{
hBorder = CreateWindowEx
(
NULL,
"Static",
"",
WS_CHILD | WS_VISIBLE | WS_BORDER,
4, 2,
196, 46,
hwnd, NULL,
ghInstance,
NULL
);
hBox1 = CreateWindowEx
(
WS_EX_RIGHT | WS_EX_CLIENTEDGE,
"Edit",
"",
WS_CHILD | WS_VISIBLE,
10, 14,
30, 20,
hwnd, NULL,
ghInstance,
NULL
);
}
break;
case WM_CLOSE:
DestroyWindow(hwnd);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hwnd, Message, wParam, lParam);
}
return 0;
}
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
WNDCLASSEX WndC;
HWND hwnd;
MSG Msg;
ghInstance = hInstance;
WndC.cbSize = sizeof(WNDCLASSEX);
WndC.style = NULL;
WndC.lpfnWndProc = WndProc;
WndC.cbClsExtra = 0;
WndC.cbWndExtra = 0;
WndC.hInstance = ghInstance;
WndC.hIcon = LoadIcon(NULL, IDI_APPLICATION);
WndC.hCursor = LoadCursor(NULL, IDC_ARROW);
WndC.hbrBackground = (HBRUSH)(COLOR_WINDOW+0);
WndC.lpszMenuName = NULL;
WndC.lpszClassName = gszClassName;
WndC.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
if(!RegisterClassEx(&WndC))
{
MessageBox(0, "Window Registration Failed!", "Error!", MB_ICONSTOP | MB_OK);
return 0;
}
hwnd = CreateWindowEx
(
WS_EX_STATICEDGE,
gszClassName,
"math_test",
WS_SYSMENU | WS_MINIMIZEBOX, //WS_OVERLAPPEDWINDOW
CW_USEDEFAULT, CW_USEDEFAULT,
210, 75,
NULL, NULL,
ghInstance,
NULL
);
if(hwnd == NULL)
{
MessageBox(0, "Window Creation Failed!", "Error!", MB_ICONSTOP | MB_OK);
return 0;
}
ShowWindow(hwnd, nCmdShow);
UpdateWindow(hwnd);
while(GetMessage(&Msg, NULL, 0, 0))
{
TranslateMessage(&Msg);
DispatchMessage(&Msg);
}
return Msg.wParam;
}