ReactOS 0.4.15-dev-8235-gcd88a97
multiwin.c
Go to the documentation of this file.
1#include <windows.h>
2#include <stdio.h>
3
6
7int WINAPI
9 HINSTANCE hPrevInstance,
10 LPSTR lpszCmdLine,
11 int nCmdShow)
12{
13 WNDCLASS wc;
14 MSG msg;
15 HWND hWnd1;
16 HWND hWnd2;
18
19 wc.lpszClassName = "MultiClass";
25 wc.hbrBackground = (HBRUSH) (COLOR_WINDOW + 1);
26 wc.lpszMenuName = NULL;
27 wc.cbClsExtra = 0;
28 wc.cbWndExtra = 0;
29 if (RegisterClass(&wc) == 0)
30 {
31 fprintf(stderr, "RegisterClass failed (last error 0x%lX)\n",
32 GetLastError());
33 return(1);
34 }
35
36 hWnd1 = CreateWindow("MultiClass",
37 "TopLevel1",
39 0,
40 0,
41 320,
42 240,
43 NULL,
44 NULL,
46 NULL);
47
48 hWndChild = CreateWindow("MultiClass",
49 "Child1 of TopLevel1",
51 20,
52 120,
53 200,
54 200,
55 hWnd1,
56 NULL,
58 NULL);
59
60 hWnd2 = CreateWindow("MultiClass",
61 "TopLevel2",
63 400,
64 0,
65 160,
66 490,
67 NULL,
68 NULL,
70 NULL);
71
72 if (! hWnd1 || ! hWnd2 || ! hWndChild)
73 {
74 fprintf(stderr, "CreateWindow failed (last error 0x%lX)\n",
75 GetLastError());
76 return(1);
77 }
78 WindowCount = 2;
79
82
83 while(GetMessage(&msg, NULL, 0, 0))
84 {
87 }
88 return msg.wParam;
89}
90
92{
93 PAINTSTRUCT ps;
94 HDC hDC;
95 LONG Style;
97 HBRUSH Brush;
98 static COLORREF Colors[] =
99 {
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)
115 };
116 static unsigned CurrentColor = 0;
117
118 switch(msg)
119 {
120 case WM_PAINT:
121 hDC = BeginPaint(hWnd, &ps);
123 Brush = CreateSolidBrush(Colors[CurrentColor]);
126 CurrentColor++;
127 if (sizeof(Colors) / sizeof(Colors[0]) <= CurrentColor)
128 {
129 CurrentColor = 0;
130 }
131 EndPaint(hWnd, &ps);
132 break;
133
134 case WM_DESTROY:
136 if (0 == (Style & WS_CHILD) && 0 == --WindowCount)
137 {
139 }
140 break;
141
142 default:
144 }
145
146 return 0;
147}
static HDC hDC
Definition: 3dtext.c:33
Colors
Definition: ansiprsr.h:4
const DWORD Style
Definition: appswitch.c:71
#define msg(x)
Definition: auth_time.c:54
HWND hWnd
Definition: settings.c:17
HINSTANCE hInstance
Definition: charmap.c:19
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
#define NULL
Definition: types.h:112
#define CALLBACK
Definition: compat.h:35
#define RGB(r, g, b)
Definition: precomp.h:71
HWND hWndChild[NUM_TABS]
Definition: main.h:74
pKey DeleteObject()
#define stderr
Definition: stdio.h:100
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
HWND hWnd1
Definition: button.c:416
HWND hWnd2
Definition: button.c:416
static HDC
Definition: imagelist.c:92
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmdLine, int nCmdShow)
Definition: multiwin.c:8
static UINT WindowCount
Definition: multiwin.c:4
LRESULT WINAPI MultiWndProc(HWND, UINT, WPARAM, LPARAM)
Definition: multiwin.c:91
unsigned int UINT
Definition: ndis.h:50
#define WS_CHILD
Definition: pedump.c:617
#define WS_CAPTION
Definition: pedump.c:624
#define WS_OVERLAPPEDWINDOW
Definition: pedump.c:637
#define WS_SYSMENU
Definition: pedump.c:629
#define WS_BORDER
Definition: pedump.c:625
#define WS_VISIBLE
Definition: pedump.c:620
long LONG
Definition: pedump.c:60
#define DefWindowProc
Definition: ros2win.h:31
Definition: client.c:28
HBRUSH hbrBackground
Definition: winuser.h:3170
HICON hIcon
Definition: winuser.h:3168
HINSTANCE hInstance
Definition: winuser.h:3167
HCURSOR hCursor
Definition: winuser.h:3169
int cbWndExtra
Definition: winuser.h:3166
UINT style
Definition: winuser.h:3163
LPCSTR lpszMenuName
Definition: winuser.h:3171
LPCSTR lpszClassName
Definition: winuser.h:3172
WNDPROC lpfnWndProc
Definition: winuser.h:3164
int cbClsExtra
Definition: winuser.h:3165
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1829
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
LONG_PTR LPARAM
Definition: windef.h:208
LONG_PTR LRESULT
Definition: windef.h:209
UINT_PTR WPARAM
Definition: windef.h:207
DWORD COLORREF
Definition: windef.h:300
#define WINAPI
Definition: msvc.h:6
int WINAPI FillRect(HDC, LPCRECT, HBRUSH)
HBRUSH WINAPI CreateSolidBrush(_In_ COLORREF)
#define WM_PAINT
Definition: winuser.h:1620
#define CS_VREDRAW
Definition: winuser.h:658
BOOL WINAPI TranslateMessage(_In_ const MSG *)
#define COLOR_WINDOW
Definition: winuser.h:918
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
__analysis_noreturn void WINAPI PostQuitMessage(_In_ int)
#define CS_HREDRAW
Definition: winuser.h:653
#define IDC_ARROW
Definition: winuser.h:687
#define IDI_APPLICATION
Definition: winuser.h:704
#define CreateWindow
Definition: winuser.h:5763
#define GetMessage
Definition: winuser.h:5799
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
BOOL WINAPI EndPaint(_In_ HWND, _In_ const PAINTSTRUCT *)
#define LoadIcon
Definition: winuser.h:5822
#define LoadCursor
Definition: winuser.h:5821
#define GetWindowLong
Definition: winuser.h:5805
#define RegisterClass
Definition: winuser.h:5845
#define WM_DESTROY
Definition: winuser.h:1609
#define DispatchMessage
Definition: winuser.h:5774
HDC WINAPI BeginPaint(_In_ HWND, _Out_ LPPAINTSTRUCT)
#define GWL_STYLE
Definition: winuser.h:852
#define SW_NORMAL
Definition: winuser.h:769
char * LPSTR
Definition: xmlstorage.h:182
const CHAR * LPCTSTR
Definition: xmlstorage.h:193