1 #include <windows.h>
2
3 LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM) ;
4
5 int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
6 PSTR szCmdLine, int iCmdShow)
7 {
8 static TCHAR szAppName[] = TEXT ("HelloWin") ;
9 HWND hwnd ;
10 MSG msg ;
11 WNDCLAS wndclass ;
12
13 wndclass.style = CS_HREDRAW | CS_VREDRAW ;
14 wndclass.lpfnWndProc = WndProc ;
15 wndclass.cbClsExtra = 0 ;
16 wndclass.cbWndExtra = 0 ;
17 wndclass.hInstance = hInstance ;
18 wndclass.hIcon = LoadIcon (NULL, IDI_APPLICATION) ;
19 wndclass.hCursor = LoadCursor (NULL, IDC_ARROW) ;
20 wndclass.hbrBackground = (HBRUSH) GetStockObject (WHITE_BRUSH) ;
21 wndclass.lpszMenuNam = NULL ;
22 wndclass.lpszClassName = szAppName ;
23
24 if (!RegisterClass (&wndclass))
25 {
26 MessageBox ( NULL, TEXT ("This program requires Windows NT!"),
27 szAppName, MB_ICONERROR) ;
28 return 0 ;
29 }
30 hwnd = CreateWindow( szAppName, // window class name
31 TEXT ("The Hello Program"), // window caption
32 WS_OVERLAPPEDWINDOW, // window style
33 CW_USEDEFAULT, // initial x position
34 CW_USEDEFAULT, // initial y position
35 CW_USEDEFAULT, // initial x size
36 CW_USEDEFAULT, // initial y size
37 NULL, // parent window handle
38 NULL, // window menu handle
39 hInstance, // program instance handle
40 NULL) ; // creation parameters
41
42 ShowWindow (hwnd, iCmdShow) ;
43 UpdateWindow (hwnd) ;
44
45 while (GetMessage (&msg, NULL, 0, 0))
46 {
47 TranslateMessage (&msg) ;
48 DispatchMessage (&msg) ;
49 }
50 return msg.wParam ;
51 }
52
53 LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
54 {
55 HDC hdc ;
56 PAINTSTRUCT ps ;
57 RECT rect ;
58
59 switch (message)
60 {
61 case WM_CREATE:
62 PlaySound (TEXT ("hellowin.wav"), NULL, SND_FILENAME | SND_ASYNC) ;
63 return 0 ;
64
65 case WM_PAINT:
66 hdc = BeginPaint (hwnd, &ps) ;
67
68 GetClientRect (hwnd, &rect) ;
69
70 DrawText (hdc, TEXT ("Hello, Windows 98!"), -1, &rect,
71 DT_SINGLELINE | DT_CENTER | DT_VCENTER) ;
72 EndPaint (hwnd, &ps) ;
73 return 0 ;
74
75 case WM_DESTROY:
76 PostQuitMessage (0) ;
77 return 0 ;
78 }
79 return DefWindowProc (hwnd, message, wParam, lParam) ;
80 }