#include LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); void OnCreate(HWND hwnd); void OnDestroy(HWND hwnd); void OnPaint(HWND hwnd, HDC hdc); char *szClassName = "Test2"; char *szWindowTitle = "Test2"; /*------------------------------------------- WinMain ---------------------------------------------*/ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { MSG msg; WNDCLASS wndclass; HWND hwnd; wndclass.style = CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS; wndclass.cbClsExtra = 0; wndclass.cbWndExtra = 0; wndclass.hInstance = hInstance; wndclass.hIcon = LoadIcon(hInstance, "MYICON"); wndclass.hCursor = LoadCursor(NULL, IDC_ARROW); wndclass.hbrBackground = (HBRUSH)(COLOR_WINDOW+1); wndclass.lpszMenuName = NULL; wndclass.lpfnWndProc = WndProc; wndclass.lpszClassName = szClassName; RegisterClass(&wndclass); hwnd = CreateWindowEx(WS_EX_CLIENTEDGE, szClassName, szWindowTitle, WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, hInstance, NULL); ShowWindow(hwnd, nCmdShow); UpdateWindow(hwnd); while(GetMessage(&msg, NULL, 0, 0)) { TranslateMessage(&msg); DispatchMessage(&msg); } return msg.wParam; } /*------------------------------------------- window procedure ---------------------------------------------*/ LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { switch (message) { case WM_CREATE: OnCreate(hwnd); return 0; case WM_DESTROY: OnDestroy(hwnd); return 0; case WM_PAINT: { PAINTSTRUCT ps; HDC hdc; hdc = BeginPaint(hwnd, &ps); OnPaint(hwnd, hdc); EndPaint(hwnd, &ps); return 0; } } return DefWindowProc(hwnd, message, wParam, lParam); } void OnCreate(HWND hwnd) { } void OnDestroy(HWND hwnd) { PostQuitMessage(0); } void OnPaint(HWND hwnd, HDC hdc) { char *msg = "hello, world"; TextOut(hdc, 0, 0, msg, strlen(msg)); }