ReactOS 0.4.15-dev-7942-gd23573b
buttontst2.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 hWnd;
16 HWND hbtn[26];
17
18 wc.lpszClassName = "ButtonTest";
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%lX)\n",
31 GetLastError());
32 return(1);
33 }
34
35 hWnd = CreateWindow("ButtonTest",
36 "Button Test",
38 0,
39 0,
42 NULL,
43 NULL,
45 NULL);
46 if (hWnd == NULL)
47 {
48 fprintf(stderr, "CreateWindow failed (last error 0x%lX)\n",
49 GetLastError());
50 return(1);
51 }
52
56
57 ShowWindow(hWnd, nCmdShow);
58
59 hbtn[0] = CreateWindow(
60 "BUTTON","BS_DEFPUSHBUTTON",WS_VISIBLE | WS_CHILD | BS_DEFPUSHBUTTON,
62
63 hbtn[1] = CreateWindow(
64 "BUTTON","BS_3STATE",WS_VISIBLE | WS_CHILD | BS_3STATE,
66
67 hbtn[2] = CreateWindow(
68 "BUTTON","BS_AUTO3STATE",WS_VISIBLE | WS_CHILD | BS_AUTO3STATE,
70
71 hbtn[3] = CreateWindow(
72 "BUTTON","BS_AUTOCHECKBOX",WS_VISIBLE | WS_CHILD | BS_AUTOCHECKBOX,
74
75 hbtn[4] = CreateWindow(
76 "BUTTON","BS_AUTORADIOBUTTON",WS_VISIBLE | WS_CHILD | BS_AUTORADIOBUTTON,
78
79 hbtn[5] = CreateWindow(
80 "BUTTON","BS_CHECKBOX",WS_VISIBLE | WS_CHILD | BS_CHECKBOX,
82
83 hbtn[6] = CreateWindow(
84 "BUTTON","BS_GROUPBOX",WS_VISIBLE | WS_CHILD | BS_GROUPBOX,
86
87 hbtn[7] = CreateWindow(
88 "BUTTON","BS_PUSHBUTTON",WS_VISIBLE | WS_CHILD | BS_PUSHBUTTON,
90
91 hbtn[8] = CreateWindow(
92 "BUTTON","BS_RADIOBUTTON",WS_VISIBLE | WS_CHILD | BS_RADIOBUTTON,
94
95 hbtn[9] = CreateWindow(
96 "BUTTON","BS_AUTORADIOBUTTON",WS_VISIBLE | WS_CHILD | BS_AUTORADIOBUTTON,
97 220, 160, 200, 20, hWnd, NULL, (HINSTANCE) GetWindowLongPtr(hWnd, GWLP_HINSTANCE),NULL);
98
99 hbtn[10] = CreateWindow(
100 "BUTTON","BS_DEFPUSHBUTTON|BS_BOTTOM",WS_VISIBLE | WS_CHILD | BS_DEFPUSHBUTTON | BS_BOTTOM,
101 220, 10, 250, 40, hWnd, NULL, (HINSTANCE) GetWindowLongPtr(hWnd, GWLP_HINSTANCE),NULL);
102
103 hbtn[11] = CreateWindow(
104 "BUTTON","BS_DEFPUSHBUTTON|BS_LEFT",WS_VISIBLE | WS_CHILD | BS_DEFPUSHBUTTON | BS_LEFT,
105 480, 10, 250, 40, hWnd, NULL, (HINSTANCE) GetWindowLongPtr(hWnd, GWLP_HINSTANCE),NULL);
106
107 hbtn[12] = CreateWindow(
108 "BUTTON","BS_DEFPUSHBUTTON|BS_RIGHT|BS_MULTILINE",WS_VISIBLE | WS_CHILD | BS_DEFPUSHBUTTON | BS_RIGHT |BS_MULTILINE,
109 740, 10, 150, 60, hWnd, NULL, (HINSTANCE) GetWindowLongPtr(hWnd, GWLP_HINSTANCE),NULL);
110
111 hbtn[13] = CreateWindow(
112 "BUTTON","BS_AUTORADIOBUTTON|BS_TOP",WS_VISIBLE | WS_CHILD | BS_AUTORADIOBUTTON | BS_TOP,
113 220, 60, 200, 60, hWnd, NULL, (HINSTANCE) GetWindowLongPtr(hWnd, GWLP_HINSTANCE),NULL);
114
115 // Other Combinations
116
117 hbtn[14] = CreateWindow(
118 "BUTTON","BS_AUTORADIOBUTTON|BS_BOTTOM|BS_MULTILINE",WS_VISIBLE | WS_CHILD | BS_AUTORADIOBUTTON | BS_BOTTOM | BS_MULTILINE,
119 480, 60, 200, 60, hWnd, NULL, (HINSTANCE) GetWindowLongPtr(hWnd, GWLP_HINSTANCE),NULL);
120
121 hbtn[15] = CreateWindow(
122 "BUTTON","BS_AUTORADIOBUTTON|BS_LEFT",WS_VISIBLE | WS_CHILD | BS_AUTORADIOBUTTON | BS_LEFT,
123 740, 80, 200, 20, hWnd, NULL, (HINSTANCE) GetWindowLongPtr(hWnd, GWLP_HINSTANCE),NULL);
124
125 hbtn[16] = CreateWindow(
126 "BUTTON","BS_AUTORADIOBUTTON|BS_RIGHT|BS_TOP",WS_VISIBLE | WS_CHILD | BS_AUTORADIOBUTTON | BS_RIGHT | BS_TOP,
127 220, 130, 200, 20, hWnd, NULL, (HINSTANCE) GetWindowLongPtr(hWnd, GWLP_HINSTANCE),NULL);
128
129 hbtn[17] = CreateWindow(
130 "BUTTON","BS_AUTORADIOBUTTON|BS_TOP|BS_MULTILINE",WS_VISIBLE | WS_CHILD | BS_AUTORADIOBUTTON | BS_TOP| BS_MULTILINE,
131 480, 130, 200, 60, hWnd, NULL, (HINSTANCE) GetWindowLongPtr(hWnd, GWLP_HINSTANCE),NULL);
132
133 hbtn[18] = CreateWindow(
134 "BUTTON","BS_AUTOCHECKBOX|BS_BOTTOM|BS_MULTILINE",WS_VISIBLE | WS_CHILD | BS_AUTOCHECKBOX | BS_BOTTOM | BS_MULTILINE,
135 740, 130, 200, 60, hWnd, NULL, (HINSTANCE) GetWindowLongPtr(hWnd, GWLP_HINSTANCE),NULL);
136
137 hbtn[19] = CreateWindow(
138 "BUTTON","BS_AUTOCHECKBOX|BS_TOP|BS_MULTILINE",WS_VISIBLE | WS_CHILD | BS_AUTOCHECKBOX | BS_TOP | BS_MULTILINE,
139 480, 190, 200, 60, hWnd, NULL, (HINSTANCE) GetWindowLongPtr(hWnd, GWLP_HINSTANCE),NULL);
140
141 hbtn[20] = CreateWindow(
142 "BUTTON","BS_AUTOCHECKBOX|BS_LEFT|BS_MULTILINE",WS_VISIBLE | WS_CHILD | BS_AUTOCHECKBOX | BS_LEFT | BS_MULTILINE,
143 220, 230, 200, 60, hWnd, NULL, (HINSTANCE) GetWindowLongPtr(hWnd, GWLP_HINSTANCE),NULL);
144
145 hbtn[21] = CreateWindow(
146 "BUTTON","BS_AUTOCHECKBOX|BS_RIGHT|BS_MULTILINE",WS_VISIBLE | WS_CHILD | BS_AUTOCHECKBOX | BS_RIGHT | BS_MULTILINE,
147 480, 240, 200, 60, hWnd, NULL, (HINSTANCE) GetWindowLongPtr(hWnd, GWLP_HINSTANCE),NULL);
148
149 hbtn[22] = CreateWindow(
150 "BUTTON","BS_GROUPBOX|BS_TOP",WS_VISIBLE | WS_CHILD | BS_GROUPBOX | BS_TOP,
151 10, 340, 200, 60, hWnd, NULL, (HINSTANCE) GetWindowLongPtr(hWnd, GWLP_HINSTANCE),NULL);
152
153 hbtn[23] = CreateWindow(
154 "BUTTON","BS_GROUPBOX|BS_BOTTOM",WS_VISIBLE | WS_CHILD | BS_GROUPBOX | BS_BOTTOM,
155 10, 410, 200, 60, hWnd, NULL, (HINSTANCE) GetWindowLongPtr(hWnd, GWLP_HINSTANCE),NULL);
156
157 hbtn[24] = CreateWindow(
158 "BUTTON","BS_GROUPBOXBOX|BS_LEFT",WS_VISIBLE | WS_CHILD | BS_GROUPBOX | BS_LEFT,
159 520, 340, 200, 60, hWnd, NULL, (HINSTANCE) GetWindowLongPtr(hWnd, GWLP_HINSTANCE),NULL);
160
161 hbtn[25] = CreateWindow(
162 "BUTTON","BS_GROUPBOX|BS_RIGHT|BS_BOTTOM",WS_VISIBLE | WS_CHILD | BS_GROUPBOX | BS_BOTTOM | BS_RIGHT,
163 300, 340, 200, 60, hWnd, NULL, (HINSTANCE) GetWindowLongPtr(hWnd, GWLP_HINSTANCE),NULL);
164
165 while(GetMessage(&msg, NULL, 0, 0))
166 {
169 }
170
172
173 return msg.wParam;
174}
175
177{
178 PAINTSTRUCT ps;
179 HDC hDC;
180
181 switch(msg)
182 {
183 case WM_PAINT:
184 hDC = BeginPaint(hWnd, &ps);
186 EndPaint(hWnd, &ps);
187 break;
188
189 case WM_DESTROY:
191 break;
192
193 case WM_COMMAND:
194 switch(HIWORD(wParam))
195 {
196 case BN_CLICKED:
197 printf("BUTTON CLICKED !\n");
198 break;
199 case BN_DBLCLK:
200 printf("BUTTON DOUBLE-CLICKED !\n");
201 break;
202 case BN_PUSHED:
203 printf("BUTTON PUSHED !\n");
204 break;
205 case BN_PAINT:
206 printf("BUTTON PAINTED !\n");
207 break;
208 case BN_UNPUSHED:
209 printf("BUTTON UNPUSHED !\n");
210 break;
211
212 }
213 break;
214
215 default:
217 }
218 return 0;
219}
static HDC hDC
Definition: 3dtext.c:33
#define msg(x)
Definition: auth_time.c:54
HWND hWnd
Definition: settings.c:17
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmdLine, int nCmdShow)
Definition: buttontst2.c:8
LRESULT WINAPI MainWndProc(HWND, UINT, WPARAM, LPARAM)
Definition: buttontst2.c:176
HFONT tf
Definition: buttontst2.c:4
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 FALSE
Definition: types.h:117
#define CALLBACK
Definition: compat.h:35
#define printf
Definition: freeldr.h:97
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,...)
static HDC
Definition: imagelist.c:92
static DWORD *static HFONT(WINAPI *pCreateFontIndirectExA)(const ENUMLOGFONTEXDVA *)
unsigned int UINT
Definition: ndis.h:50
#define BS_AUTORADIOBUTTON
Definition: pedump.c:660
#define WS_CHILD
Definition: pedump.c:617
#define WS_OVERLAPPEDWINDOW
Definition: pedump.c:637
#define WS_VISIBLE
Definition: pedump.c:620
#define BS_AUTOCHECKBOX
Definition: pedump.c:654
#define BS_GROUPBOX
Definition: pedump.c:658
#define BS_3STATE
Definition: pedump.c:656
#define BS_CHECKBOX
Definition: pedump.c:653
#define BS_AUTO3STATE
Definition: pedump.c:657
#define BS_RADIOBUTTON
Definition: pedump.c:655
#define BS_PUSHBUTTON
Definition: pedump.c:651
#define BS_DEFPUSHBUTTON
Definition: pedump.c:652
#define DefWindowProc
Definition: ros2win.h:31
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
#define GetWindowLongPtr
Definition: treelist.c:73
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1829
#define HIWORD(l)
Definition: typedefs.h:247
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
#define WINAPI
Definition: msvc.h:6
#define FIXED_PITCH
Definition: wingdi.h:444
HGDIOBJ WINAPI GetStockObject(_In_ int)
#define DEFAULT_QUALITY
Definition: wingdi.h:436
#define FF_DONTCARE
Definition: wingdi.h:448
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1539
#define GRAY_BRUSH
Definition: wingdi.h:898
#define OUT_DEFAULT_PRECIS
Definition: wingdi.h:415
#define ANSI_CHARSET
Definition: wingdi.h:383
#define CLIP_DEFAULT_PRECIS
Definition: wingdi.h:426
#define FW_NORMAL
Definition: wingdi.h:373
#define TA_BASELINE
Definition: wingdi.h:928
HFONT WINAPI CreateFontA(_In_ int, _In_ int, _In_ int, _In_ int, _In_ int, _In_ DWORD, _In_ DWORD, _In_ DWORD, _In_ DWORD, _In_ DWORD, _In_ DWORD, _In_ DWORD, _In_ DWORD, _In_opt_ LPCSTR)
#define WM_PAINT
Definition: winuser.h:1620
#define CS_VREDRAW
Definition: winuser.h:658
#define BN_DBLCLK
Definition: winuser.h:1926
BOOL WINAPI TranslateMessage(_In_ const MSG *)
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
#define BS_RIGHT
Definition: winuser.h:274
#define BN_UNPUSHED
Definition: winuser.h:1935
__analysis_noreturn void WINAPI PostQuitMessage(_In_ int)
#define WM_COMMAND
Definition: winuser.h:1740
#define CS_HREDRAW
Definition: winuser.h:653
#define IDC_ARROW
Definition: winuser.h:687
#define BS_BOTTOM
Definition: winuser.h:259
#define GWLP_HINSTANCE
Definition: winuser.h:856
#define BN_PUSHED
Definition: winuser.h:1932
#define IDI_APPLICATION
Definition: winuser.h:704
#define CreateWindow
Definition: winuser.h:5754
#define BS_MULTILINE
Definition: winuser.h:267
#define GetMessage
Definition: winuser.h:5790
#define BS_LEFT
Definition: winuser.h:265
BOOL WINAPI EndPaint(_In_ HWND, _In_ const PAINTSTRUCT *)
#define LoadIcon
Definition: winuser.h:5813
#define LoadCursor
Definition: winuser.h:5812
#define BS_TOP
Definition: winuser.h:277
#define CW_USEDEFAULT
Definition: winuser.h:225
#define BN_CLICKED
Definition: winuser.h:1925
#define RegisterClass
Definition: winuser.h:5836
#define WM_DESTROY
Definition: winuser.h:1609
#define DispatchMessage
Definition: winuser.h:5765
HDC WINAPI BeginPaint(_In_ HWND, _Out_ LPPAINTSTRUCT)
#define BN_PAINT
Definition: winuser.h:1931
char * LPSTR
Definition: xmlstorage.h:182
const CHAR * LPCTSTR
Definition: xmlstorage.h:193