b30021923be63e45956d2238e88e53913d7cdb4a
[reactos.git] / reactos / apps / tests / multiwin / multiwin.c
1 #include <windows.h>
2 #include <stdio.h>
3
4 HFONT tf;
5 LRESULT WINAPI MainWndProc(HWND, UINT, WPARAM, LPARAM);
6
7 int WINAPI
8 WinMain(HINSTANCE hInstance,
9 HINSTANCE hPrevInstance,
10 LPSTR lpszCmdLine,
11 int nCmdShow)
12 {
13 WNDCLASS wc;
14 MSG msg;
15 HWND hWnd;
16 HWND hWnd2;
17
18 wc.lpszClassName = "MultiWinClass";
19 wc.lpfnWndProc = MainWndProc;
20 wc.style = CS_VREDRAW | CS_HREDRAW;
21 wc.hInstance = hInstance;
22 wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
23 wc.hCursor = LoadCursor(NULL, IDC_ARROW);
24 wc.hbrBackground = (HBRUSH)GetStockObject(GRAY_BRUSH);
25 wc.lpszMenuName = NULL;
26 wc.cbClsExtra = 0;
27 wc.cbWndExtra = 0;
28 if (RegisterClass(&wc) == 0)
29 {
30 fprintf(stderr, "RegisterClass failed (last error 0x%X)\n",
31 GetLastError());
32 return(1);
33 }
34
35 hWnd = CreateWindow("MultiWinClass",
36 "Window1",
37 WS_OVERLAPPEDWINDOW|WS_VISIBLE,
38 0,
39 0,
40 320,
41 240,
42 NULL,
43 NULL,
44 hInstance,
45 NULL);
46
47 hWnd2 = hWnd = CreateWindow("MultiWinClass",
48 "Window2",
49 WS_CAPTION|WS_SYSMENU|WS_VISIBLE,
50 400,
51 0,
52 160,
53 120,
54 NULL,
55 NULL,
56 hInstance,
57 NULL);
58
59 if (!hWnd || !hWnd2)
60 {
61 fprintf(stderr, "CreateWindow failed (last error 0x%X)\n",
62 GetLastError());
63 return(1);
64 }
65 ShowWindow(hWnd, nCmdShow);
66
67 while(GetMessage(&msg, NULL, 0, 0))
68 {
69 TranslateMessage(&msg);
70 DispatchMessage(&msg);
71 }
72 return msg.wParam;
73 }
74
75 LRESULT CALLBACK MainWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
76 {
77 PAINTSTRUCT ps;
78 HDC hDC;
79
80 switch(msg)
81 {
82 case WM_PAINT:
83 hDC = BeginPaint(hWnd, &ps);
84 EndPaint(hWnd, &ps);
85 break;
86
87 case WM_DESTROY:
88 PostQuitMessage(0);
89 break;
90
91 default:
92 return DefWindowProc(hWnd, msg, wParam, lParam);
93 }
94 return 0;
95 }