/* phello.c */ #include #include #include LONG CALLBACK _export MainWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { PAINTSTRUCT ps; HDC hDC; int x,y; char s[100]; switch ( message ) { case WM_PAINT: if ( BeginPaint(hWnd,&ps) ) TextOut(ps.hdc, 10, 10, "Hello World!",12); EndPaint(hWnd,&ps); return 0; case WM_LBUTTONDOWN: hDC = GetDC(hWnd); x = LOWORD(lParam); y = HIWORD(lParam); sprintf(s,"(%d,%d)",x,y); TextOut(hDC,x,y,s,strlen(s)); ReleaseDC(hWnd,hDC); return 0; case WM_DESTROY: PostQuitMessage(0); return 0; default: break; } return DefWindowProc(hWnd, message, wParam, lParam); } int PASCAL WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { WNDCLASS wc; HWND hWnd; MSG msg; (void)lpCmdLine; if (!hPrevInstance) { wc.style = 0; wc.lpfnWndProc = MainWndProc; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hInstance = hInstance; wc.hIcon = LoadIcon(NULL, IDI_APPLICATION); wc.hCursor = LoadCursor(NULL, IDC_ARROW); wc.hbrBackground = GetStockObject(WHITE_BRUSH); wc.lpszMenuName = NULL; wc.lpszClassName = "WHelloWClass"; if (!RegisterClass(&wc)) return 1; } hWnd = CreateWindow("WHelloWClass","Windows Hello",WS_OVERLAPPEDWINDOW, CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT, NULL,NULL,hInstance,NULL); if ( !hWnd ) return 1; ShowWindow(hWnd, nCmdShow); UpdateWindow(hWnd); while (GetMessage(&msg,NULL,0,0)) { TranslateMessage(&msg); DispatchMessage(&msg); } return msg.wParam; }