#include LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); char szClassNme[] = "sample window"; int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPreInst, LPSTR lpCmdLine, int nCmdShow) { HWND hWnd; MSG msg; WNDCLASS wndcls; if (!hPreInst) { wndcls.style = CS_HREDRAW | CS_VREDRAW; wndcls.lpfnWndProc = WndProc; wndcls.cbClsExtra = 0; wndcls.cbWndExtra = 0; wndcls.hInstance = hInstance; wndcls.hIcon = NULL; wndcls.hCursor = LoadCursor(NULL, IDC_ARROW); wndcls.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH); wndcls.lpszMenuName = NULL; wndcls.lpszClassName = szClassNme; if (!RegisterClass(&wndcls)) return FALSE; } hWnd = CreateWindow(szClassNme, lpCmdLine, WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, 320, 240, NULL, NULL, hInstance, NULL); ShowWindow(hWnd, nCmdShow); UpdateWindow(hWnd); while(1){ if(PeekMessage(&msg,0,0,0,PM_REMOVE)){ if(msg.message == WM_QUIT) return 0; TranslateMessage(&msg); DispatchMessage(&msg); } } } LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) { switch (msg) { case WM_DESTROY: PostQuitMessage(0); break; case WM_PAINT: { HDC hDC=GetDC(hWnd); for(int a=0;a<100;++a) SetPixelV(hDC,a+100,a+100,RGB(255,0,0)); ReleaseDC(hWnd,hDC); } break; default: return(DefWindowProc(hWnd, msg, wParam, lParam)); } return (0L); }