4 static UINT WindowCount
;
5 LRESULT WINAPI
MultiWndProc(HWND
, UINT
, WPARAM
, LPARAM
);
8 WinMain(HINSTANCE hInstance
,
9 HINSTANCE hPrevInstance
,
19 wc
.lpszClassName
= "MultiClass";
20 wc
.lpfnWndProc
= MultiWndProc
;
21 wc
.style
= CS_VREDRAW
| CS_HREDRAW
;
22 wc
.hInstance
= hInstance
;
23 wc
.hIcon
= LoadIcon(NULL
, (LPCTSTR
) IDI_APPLICATION
);
24 wc
.hCursor
= LoadCursor(NULL
, (LPCTSTR
) IDC_ARROW
);
25 wc
.hbrBackground
= (HBRUSH
) (COLOR_WINDOW
+ 1);
26 wc
.lpszMenuName
= NULL
;
29 if (RegisterClass(&wc
) == 0)
31 fprintf(stderr
, "RegisterClass failed (last error 0x%lX)\n",
36 hWnd1
= CreateWindow("MultiClass",
48 hWndChild
= CreateWindow("MultiClass",
49 "Child1 of TopLevel1",
50 WS_CHILD
| WS_BORDER
| WS_CAPTION
| WS_VISIBLE
| WS_SYSMENU
,
60 hWnd2
= CreateWindow("MultiClass",
72 if (! hWnd1
|| ! hWnd2
|| ! hWndChild
)
74 fprintf(stderr
, "CreateWindow failed (last error 0x%lX)\n",
80 ShowWindow(hWnd1
, SW_NORMAL
);
81 ShowWindow(hWnd2
, SW_NORMAL
);
83 while(GetMessage(&msg
, NULL
, 0, 0))
85 TranslateMessage(&msg
);
86 DispatchMessage(&msg
);
91 LRESULT CALLBACK
MultiWndProc(HWND hWnd
, UINT msg
, WPARAM wParam
, LPARAM lParam
)
98 static COLORREF Colors
[] =
100 RGB(0x00, 0x00, 0x00),
101 RGB(0x80, 0x00, 0x00),
102 RGB(0x00, 0x80, 0x00),
103 RGB(0x00, 0x00, 0x80),
104 RGB(0x80, 0x80, 0x00),
105 RGB(0x80, 0x00, 0x80),
106 RGB(0x00, 0x80, 0x80),
107 RGB(0x80, 0x80, 0x80),
108 RGB(0xff, 0x00, 0x00),
109 RGB(0x00, 0xff, 0x00),
110 RGB(0x00, 0x00, 0xff),
111 RGB(0xff, 0xff, 0x00),
112 RGB(0xff, 0x00, 0xff),
113 RGB(0x00, 0xff, 0xff),
114 RGB(0xff, 0xff, 0xff)
116 static unsigned CurrentColor
= 0;
121 hDC
= BeginPaint(hWnd
, &ps
);
122 GetClientRect(hWnd
, &Client
);
123 Brush
= CreateSolidBrush(Colors
[CurrentColor
]);
124 FillRect(hDC
, &Client
, Brush
);
127 if (sizeof(Colors
) / sizeof(Colors
[0]) <= CurrentColor
)
135 Style
= GetWindowLong(hWnd
, GWL_STYLE
);
136 if (0 == (Style
& WS_CHILD
) && 0 == --WindowCount
)
143 return DefWindowProc(hWnd
, msg
, wParam
, lParam
);