#include #include LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); BOOL InitApplication(HINSTANCE hInstance); BOOL InitInstance(HINSTANCE, int); int PASCAL WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { MSG msg; if(!InitApplication(hInstance)) { return FALSE; } if(!InitInstance(hInstance, nCmdShow)) { return FALSE; } while(GetMessage(&msg, NULL, 0,0)) { TranslateMessage(&msg); DispatchMessage(&msg); } return msg.wParam; } BOOL InitApplication(HINSTANCE hInstance) { WNDCLASS wc; wc.style = CS_HREDRAW | CS_VREDRAW; wc.lpfnWndProc = (WNDPROC) WndProc; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hInstance = hInstance; wc.hIcon = LoadIcon(NULL, IDI_APPLICATION); wc.hCursor = LoadCursor(NULL, IDC_ARROW); wc.hbrBackground= (HBRUSH)GetStockObject(WHITE_BRUSH); wc.lpszMenuName = NULL; wc.lpszClassName= "test"; return RegisterClass(&wc); } BOOL InitInstance(HINSTANCE hInstance, int nCmdShow) { HWND hWnd; hWnd = CreateWindow("test","TestApp",WS_OVERLAPPEDWINDOW, 160,120,320,240, NULL,NULL, hInstance, NULL); if(!hWnd) { return FALSE; } ShowWindow(hWnd, nCmdShow); UpdateWindow(hWnd); return TRUE; } LRESULT CALLBACK WndProc(HWND hWnd, UINT uMessage, WPARAM wParam, LPARAM lParam) { HDC hDC; PAINTSTRUCT ps; char szText[] ="Hello!"; switch(uMessage) { case WM_PAINT: BeginPaint(hWnd, &ps); hDC = ps.hdc; TextOut(hDC, 0,0,szText,strlen(szText)); EndPaint(hWnd,&ps); break; case WM_DESTROY: PostQuitMessage(0); break; default: return DefWindowProc(hWnd, uMessage, wParam, lParam); } return 0; }