ReactOS  0.4.13-dev-551-gf37fb1f
multiwin.c File Reference
#include <windows.h>
#include <stdio.h>
Include dependency graph for multiwin.c:

Go to the source code of this file.

Functions

LRESULT WINAPI MultiWndProc (HWND, UINT, WPARAM, LPARAM)
 
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmdLine, int nCmdShow)
 

Variables

static UINT WindowCount
 

Function Documentation

◆ MultiWndProc()

LRESULT WINAPI MultiWndProc ( HWND  hWnd,
UINT  msg,
WPARAM  wParam,
LPARAM  lParam 
)

Definition at line 91 of file multiwin.c.

92 {
93  PAINTSTRUCT ps;
94  HDC hDC;
95  LONG Style;
96  RECT Client;
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]);
124  FillRect(hDC, &Client, Brush);
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  {
138  PostQuitMessage(0);
139  }
140  break;
141 
142  default:
143  return DefWindowProc(hWnd, msg, wParam, lParam);
144  }
145 
146  return 0;
147 }
Definition: client.c:29
static HDC
Definition: imagelist.c:92
HWND hWnd
Definition: settings.c:17
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
static UINT WindowCount
Definition: multiwin.c:4
#define WS_CHILD
Definition: pedump.c:617
BOOL WINAPI EndPaint(_In_ HWND, _In_ const PAINTSTRUCT *)
WPARAM wParam
Definition: combotst.c:138
long LONG
Definition: pedump.c:60
HDC WINAPI BeginPaint(_In_ HWND, _Out_ LPPAINTSTRUCT)
void Brush(HDC hdc, LONG x1, LONG y1, LONG x2, LONG y2, COLORREF color, LONG style)
Definition: drawing.cpp:160
#define DefWindowProc
Definition: ros2win.h:31
#define WM_DESTROY
Definition: winuser.h:1591
const DWORD Style
Definition: appswitch.c:71
DWORD COLORREF
Definition: windef.h:285
Colors
Definition: ansiprsr.h:4
#define RGB(r, g, b)
Definition: wingdi.h:2918
#define WM_PAINT
Definition: winuser.h:1602
#define GetWindowLong
Definition: winuser.h:5662
#define GWL_STYLE
Definition: winuser.h:846
static HDC hDC
Definition: 3dtext.c:33
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
HBRUSH WINAPI CreateSolidBrush(_In_ COLORREF)
#define msg(x)
Definition: auth_time.c:54
int WINAPI FillRect(HDC, LPCRECT, HBRUSH)
LPARAM lParam
Definition: combotst.c:139
__analysis_noreturn void WINAPI PostQuitMessage(_In_ int)

Referenced by WinMain().

◆ WinMain()

int WINAPI WinMain ( HINSTANCE  hInstance,
HINSTANCE  hPrevInstance,
LPSTR  lpszCmdLine,
int  nCmdShow 
)

Definition at line 8 of file multiwin.c.

12 {
13  WNDCLASS wc;
14  MSG msg;
15  HWND hWnd1;
16  HWND hWnd2;
18 
19  wc.lpszClassName = "MultiClass";
22  wc.hInstance = hInstance;
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,
45  hInstance,
46  NULL);
47 
48  hWndChild = CreateWindow("MultiClass",
49  "Child1 of TopLevel1",
51  20,
52  120,
53  200,
54  200,
55  hWnd1,
56  NULL,
57  hInstance,
58  NULL);
59 
60  hWnd2 = CreateWindow("MultiClass",
61  "TopLevel2",
63  400,
64  0,
65  160,
66  490,
67  NULL,
68  NULL,
69  hInstance,
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 }
#define SW_NORMAL
Definition: winuser.h:763
#define DispatchMessage
Definition: winuser.h:5631
BOOL WINAPI TranslateMessage(_In_ const MSG *)
const CHAR * LPCTSTR
Definition: xmlstorage.h:193
#define CreateWindow
Definition: winuser.h:5620
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1827
int cbClsExtra
Definition: winuser.h:3118
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
#define CS_HREDRAW
Definition: winuser.h:648
LPCSTR lpszMenuName
Definition: winuser.h:3124
static UINT WindowCount
Definition: multiwin.c:4
#define IDI_APPLICATION
Definition: winuser.h:699
HBRUSH hbrBackground
Definition: winuser.h:3123
#define WS_CHILD
Definition: pedump.c:617
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
HWND hWnd1
Definition: button.c:416
#define COLOR_WINDOW
Definition: winuser.h:908
int cbWndExtra
Definition: winuser.h:3119
HINSTANCE hInstance
Definition: charmap.c:20
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
HCURSOR hCursor
Definition: winuser.h:3122
smooth NULL
Definition: ftsmooth.c:416
#define WS_CAPTION
Definition: pedump.c:624
#define CS_VREDRAW
Definition: winuser.h:653
HWND hWnd2
Definition: button.c:416
LPCSTR lpszClassName
Definition: winuser.h:3125
#define LoadCursor
Definition: winuser.h:5678
UINT style
Definition: winuser.h:3116
#define WS_BORDER
Definition: pedump.c:625
HINSTANCE hInstance
Definition: winuser.h:3120
LRESULT WINAPI MultiWndProc(HWND, UINT, WPARAM, LPARAM)
Definition: multiwin.c:91
#define GetMessage
Definition: winuser.h:5656
WNDPROC lpfnWndProc
Definition: winuser.h:3117
#define msg(x)
Definition: auth_time.c:54
#define IDC_ARROW
Definition: winuser.h:682
#define WS_OVERLAPPEDWINDOW
Definition: pedump.c:637
FILE * stderr
#define RegisterClass
Definition: winuser.h:5702
#define LoadIcon
Definition: winuser.h:5679
HWND hWndChild[NUM_TABS]
Definition: main.h:75
#define WS_VISIBLE
Definition: pedump.c:620
#define WS_SYSMENU
Definition: pedump.c:629
HICON hIcon
Definition: winuser.h:3121

Variable Documentation

◆ WindowCount

UINT WindowCount
static

Definition at line 4 of file multiwin.c.

Referenced by GuiConsoleInputThread(), GuiConsoleNotifyWndProc(), MultiWndProc(), and WinMain().