#include<Windows.h> LRESULT CALLBACK WindowProc(HWND,UINT,WPARAM,LPARAM); int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int iCmdShow ) { TCHAR szAppName[] = TEXT("KeyView1"); HWND hwnd; MSG msg; WNDCLASSEX wndClass; wndClass.cbSize = sizeof(WNDCLASSEX); wndClass.cbClsExtra = 0; wndClass.cbWndExtra = 0; wndClass.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH); wndClass.hCursor = LoadCursor(NULL,IDC_ARROW); wndClass.hIcon = LoadIcon(NULL,IDI_APPLICATION); wndClass.hIconSm = LoadIcon(NULL,IDI_APPLICATION); wndClass.hInstance = hInstance; wndClass.lpfnWndProc = WindowProc; wndClass.lpszClassName = szAppName; wndClass.lpszMenuName = NULL; wndClass.style = CS_VREDRAW|CS_HREDRAW; if(!RegisterClassEx(&wndClass)) { MessageBox(NULL,TEXT("it requires Windows NT!"),TEXT("TIPS"),0); return -1; } hwnd = CreateWindow( szAppName,TEXT("KeyView1 Window"), WS_OVERLAPPEDWINDOW, CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT, NULL,NULL,hInstance,NULL ); ShowWindow(hwnd,iCmdShow); UpdateWindow(hwnd); while(GetMessage(&msg,0,0,0)) { TranslateMessage(&msg); DispatchMessage(&msg); } return msg.wParam; } LRESULT CALLBACK WindowProc(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam) { HDC hdc; PAINTSTRUCT ps; switch(message) { case WM_CREATE: break; case WM_PAINT: hdc = BeginPaint(hwnd,&ps); EndPaint(hwnd,&ps); break; case WM_DESTROY: PostQuitMessage(0); break; } return DefWindowProc(hwnd,message,wParam,lParam); }