ReactOS 0.4.15-dev-7842-g558ab78
enumwnd.c File Reference
#include <windows.h>
#include <tchar.h>
#include <stdio.h>
Include dependency graph for enumwnd.c:

Go to the source code of this file.

Classes

struct  _EnumData
 

Typedefs

typedef struct _EnumData EnumData
 

Functions

LRESULT WINAPI MainWndProc (HWND, UINT, WPARAM, LPARAM)
 
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmdLine, int nCmdShow)
 
void MyTextOut (HDC hdc, int x, int y, const TCHAR *text)
 
BOOL CALLBACK MyWindowEnumProc (HWND hwnd, LPARAM lParam)
 

Variables

HBRUSH hbrBackground
 
HFONT tf
 
int test = 0
 
const TCHARAPP_NAME = "EnumWnd Test"
 
const TCHARCLASS_NAME = "EnumWndTestClass"
 

Typedef Documentation

◆ EnumData

Function Documentation

◆ MainWndProc()

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

Definition at line 109 of file enumwnd.c.

110{
111 PAINTSTRUCT ps;
112 HDC hDC;
113 RECT rect;
114 TCHAR buf[100];
115 EnumData ed;
116
117 switch(msg)
118 {
119 case WM_PAINT:
120 hDC = BeginPaint(hWnd, &ps);
122
123 GetClientRect ( hWnd, &rect );
125
126 MyTextOut ( hDC, 10, 10, "EnumWnd Test" );
127
128 _sntprintf ( buf, sizeof(buf)/sizeof(*buf), _T("My HWND: %x"), hWnd );
129 MyTextOut ( hDC, 10, 30, buf );
130
131 ed.hdc = hDC;
132 ed.x = 10;
133 ed.y = 70;
134
135 switch ( test )
136 {
137 case 1:
138 MyTextOut ( hDC, 10, 50, _T("Test #1: EnumWindows()") );
140 break;
141 case 2:
142 MyTextOut ( hDC, 10, 50, _T("Test #2: EnumChildWindows()") );
144 break;
145 case 3:
146 MyTextOut ( hDC, 10, 50, _T("Test #3: EnumDesktopWindows") );
148 break;
149 case 4:
150 MyTextOut ( hDC, 10, 50, _T("Test #4: EnumThreadWindows") );
152 break;
153 default:
154 MyTextOut ( hDC, 10, 50, _T("Press any of the number keys from 1 to 4 to run a test") );
155 MyTextOut ( hDC, 10, 70, _T("Press the left and right mouse buttons to cycle through the tests") );
156 break;
157 }
158
159 EndPaint(hWnd, &ps);
160 break;
161
162 case WM_CHAR:
163 test = (TCHAR)wParam - '1' + 1;
165 break;
166
167 case WM_LBUTTONDOWN:
168 if ( ++test > 4 )
169 test = 1;
171 break;
172
173 case WM_RBUTTONDOWN:
174 if ( !--test )
175 test = 4;
177 break;
178
179 case WM_DESTROY:
181 break;
182
183 default:
185 }
186 return 0;
187}
static HDC hDC
Definition: 3dtext.c:33
#define msg(x)
Definition: auth_time.c:54
HWND hWnd
Definition: settings.c:17
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
#define NULL
Definition: types.h:112
int test
Definition: enumwnd.c:14
HBRUSH hbrBackground
Definition: enumwnd.c:12
BOOL CALLBACK MyWindowEnumProc(HWND hwnd, LPARAM lParam)
Definition: enumwnd.c:98
HFONT tf
Definition: enumwnd.c:13
void MyTextOut(HDC hdc, int x, int y, const TCHAR *text)
Definition: enumwnd.c:86
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
static HDC
Definition: imagelist.c:92
#define DefWindowProc
Definition: ros2win.h:31
& rect
Definition: startmenu.cpp:1413
int x
Definition: enumwnd.c:94
HDC hdc
Definition: enumwnd.c:93
int y
Definition: enumwnd.c:95
#define _T(x)
Definition: vfdio.h:22
DWORD WINAPI GetCurrentThreadId(void)
Definition: thread.c:459
LONG_PTR LPARAM
Definition: windef.h:208
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1539
int WINAPI FillRect(HDC, LPCRECT, HBRUSH)
#define WM_PAINT
Definition: winuser.h:1620
BOOL WINAPI RedrawWindow(_In_opt_ HWND, _In_opt_ LPCRECT, _In_opt_ HRGN, _In_ UINT)
__analysis_noreturn void WINAPI PostQuitMessage(_In_ int)
#define WM_LBUTTONDOWN
Definition: winuser.h:1776
BOOL WINAPI EnumChildWindows(_In_opt_ HWND, _In_ WNDENUMPROC, _In_ LPARAM)
#define WM_RBUTTONDOWN
Definition: winuser.h:1779
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
BOOL WINAPI EnumWindows(_In_ WNDENUMPROC lpEnumFunc, _In_ LPARAM lParam)
BOOL WINAPI EndPaint(_In_ HWND, _In_ const PAINTSTRUCT *)
#define WM_CHAR
Definition: winuser.h:1717
BOOL WINAPI EnumDesktopWindows(_In_opt_ HDESK, _In_ WNDENUMPROC, _In_ LPARAM)
#define WM_DESTROY
Definition: winuser.h:1609
HDC WINAPI BeginPaint(_In_ HWND, _Out_ LPPAINTSTRUCT)
BOOL WINAPI EnumThreadWindows(_In_ DWORD, _In_ WNDENUMPROC, _In_ LPARAM)
#define RDW_INVALIDATE
Definition: winuser.h:1214
char TCHAR
Definition: xmlstorage.h:189
#define _sntprintf
Definition: xmlstorage.h:201

Referenced by WinMain().

◆ MyTextOut()

void MyTextOut ( HDC  hdc,
int  x,
int  y,
const TCHAR text 
)

Definition at line 86 of file enumwnd.c.

87{
88 TextOut ( hdc, x, y, text, _tcslen(text) );
89}
const WCHAR * text
Definition: package.c:1799
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
HDC hdc
Definition: main.c:9
#define TextOut
Definition: wingdi.h:4483
#define _tcslen
Definition: xmlstorage.h:198

Referenced by MainWndProc(), and MyWindowEnumProc().

◆ MyWindowEnumProc()

BOOL CALLBACK MyWindowEnumProc ( HWND  hwnd,
LPARAM  lParam 
)

Definition at line 98 of file enumwnd.c.

99{
100 TCHAR wndcaption[1024], buf[1024];
101 EnumData* ped = (EnumData*)lParam;
102 GetWindowText ( hwnd, wndcaption, sizeof(wndcaption)/sizeof(*wndcaption) );
103 _sntprintf ( buf, sizeof(buf)/sizeof(*buf), _T("%x - %s"), hwnd, wndcaption );
104 MyTextOut ( ped->hdc, ped->x, ped->y, buf );
105 ped->y += 13;
106 return TRUE;
107}
#define TRUE
Definition: types.h:120
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023
#define GetWindowText
Definition: winuser.h:5798

Referenced by MainWndProc().

◆ WinMain()

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

Definition at line 21 of file enumwnd.c.

25{
26 WNDCLASS wc;
27 MSG msg;
28 HWND hWnd;
29
37 wc.lpszMenuName = NULL;
38 wc.cbClsExtra = 0;
39 wc.cbWndExtra = 0;
40 if (RegisterClass(&wc) == 0)
41 {
42 _ftprintf ( stderr, _T("RegisterClass failed (last error 0x%lX)\n"),
43 GetLastError());
44 return(1);
45 }
46
50 0,
51 0,
54 NULL,
55 NULL,
57 NULL);
58 if (hWnd == NULL)
59 {
60 _ftprintf ( stderr, _T("CreateWindow failed (last error 0x%lX)\n"),
61 GetLastError());
62 return(1);
63 }
64
68
69 hbrBackground = CreateSolidBrush ( RGB(192,192,192) );
70
71 ShowWindow ( hWnd, nCmdShow );
72
73 while(GetMessage(&msg, NULL, 0, 0))
74 {
77 }
78
80
82
83 return msg.wParam;
84}
HINSTANCE hInstance
Definition: charmap.c:19
#define FALSE
Definition: types.h:117
#define RGB(r, g, b)
Definition: precomp.h:71
const TCHAR * CLASS_NAME
Definition: enumwnd.c:16
LRESULT WINAPI MainWndProc(HWND, UINT, WPARAM, LPARAM)
Definition: enumwnd.c:109
const TCHAR * APP_NAME
Definition: enumwnd.c:15
pKey DeleteObject()
#define stderr
Definition: stdio.h:100
#define _ftprintf
Definition: tchar.h:518
#define WS_OVERLAPPEDWINDOW
Definition: pedump.c:637
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
#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
#define GRAY_BRUSH
Definition: wingdi.h:898
#define OUT_DEFAULT_PRECIS
Definition: wingdi.h:415
#define CreateFont
Definition: wingdi.h:4443
#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
HBRUSH WINAPI CreateSolidBrush(_In_ COLORREF)
#define CS_VREDRAW
Definition: winuser.h:658
BOOL WINAPI TranslateMessage(_In_ const MSG *)
BOOL WINAPI ShowWindow(_In_ HWND, _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:5754
#define GetMessage
Definition: winuser.h:5790
#define LoadIcon
Definition: winuser.h:5813
#define LoadCursor
Definition: winuser.h:5812
#define CW_USEDEFAULT
Definition: winuser.h:225
#define RegisterClass
Definition: winuser.h:5836
#define DispatchMessage
Definition: winuser.h:5765
const CHAR * LPCTSTR
Definition: xmlstorage.h:193

Variable Documentation

◆ APP_NAME

const TCHAR* APP_NAME = "EnumWnd Test"

Definition at line 15 of file enumwnd.c.

Referenced by WinMain().

◆ CLASS_NAME

◆ hbrBackground

◆ test

int test = 0

Definition at line 14 of file enumwnd.c.

Referenced by MainWndProc().

◆ tf

HFONT tf

Definition at line 13 of file enumwnd.c.

Referenced by MainWndProc(), and WinMain().