ReactOS  0.4.15-dev-1018-g0695ecb
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);
121  SelectObject(hDC, tf);
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:
180  PostQuitMessage(0);
181  break;
182 
183  default:
184  return DefWindowProc(hWnd, msg, wParam, lParam);
185  }
186  return 0;
187 }
BOOL WINAPI EnumChildWindows(_In_opt_ HWND, _In_ WNDENUMPROC, _In_ LPARAM)
BOOL WINAPI RedrawWindow(_In_opt_ HWND, _In_opt_ LPCRECT, _In_opt_ HRGN, _In_ UINT)
#define WM_CHAR
Definition: winuser.h:1699
#define WM_LBUTTONDOWN
Definition: winuser.h:1758
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
static HDC
Definition: imagelist.c:92
HBRUSH hbrBackground
Definition: enumwnd.c:12
HWND hWnd
Definition: settings.c:17
BOOL WINAPI EnumThreadWindows(_In_ DWORD, _In_ WNDENUMPROC, _In_ LPARAM)
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1499
BOOL WINAPI EndPaint(_In_ HWND, _In_ const PAINTSTRUCT *)
& rect
Definition: startmenu.cpp:1413
WPARAM wParam
Definition: combotst.c:138
BOOL WINAPI EnumDesktopWindows(_In_opt_ HDESK, _In_ WNDENUMPROC, _In_ LPARAM)
HDC WINAPI BeginPaint(_In_ HWND, _Out_ LPPAINTSTRUCT)
smooth NULL
Definition: ftsmooth.c:416
LONG_PTR LPARAM
Definition: windef.h:208
DWORD WINAPI GetCurrentThreadId(VOID)
Definition: thread.c:458
#define DefWindowProc
Definition: ros2win.h:31
#define WM_DESTROY
Definition: winuser.h:1591
#define WM_RBUTTONDOWN
Definition: winuser.h:1761
char TCHAR
Definition: xmlstorage.h:189
#define _T(x)
Definition: vfdio.h:22
BOOL WINAPI EnumWindows(_In_ WNDENUMPROC, _In_ LPARAM)
#define WM_PAINT
Definition: winuser.h:1602
BOOL CALLBACK MyWindowEnumProc(HWND hwnd, LPARAM lParam)
Definition: enumwnd.c:98
#define _sntprintf
Definition: xmlstorage.h:201
void MyTextOut(HDC hdc, int x, int y, const TCHAR *text)
Definition: enumwnd.c:86
HFONT tf
Definition: enumwnd.c:13
static HDC hDC
Definition: 3dtext.c:33
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
#define msg(x)
Definition: auth_time.c:54
int test
Definition: enumwnd.c:14
int WINAPI FillRect(HDC, LPCRECT, HBRUSH)
EXTENT_DATA * ed
Definition: write.c:2804
LPARAM lParam
Definition: combotst.c:139
__analysis_noreturn void WINAPI PostQuitMessage(_In_ int)
#define RDW_INVALIDATE
Definition: winuser.h:1200

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:1827
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
size_t __cdecl _tcslen(const _TCHAR *str)
Definition: tcslen.h:9
HDC hdc
Definition: main.c:9
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
#define TextOut
Definition: wingdi.h:4482

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 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
int x
Definition: enumwnd.c:94
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
#define TRUE
Definition: types.h:120
HDC hdc
Definition: enumwnd.c:93
#define GetWindowText
Definition: winuser.h:5773
char TCHAR
Definition: xmlstorage.h:189
#define _T(x)
Definition: vfdio.h:22
#define _sntprintf
Definition: xmlstorage.h:201
void MyTextOut(HDC hdc, int x, int y, const TCHAR *text)
Definition: enumwnd.c:86
int y
Definition: enumwnd.c:95
LPARAM lParam
Definition: combotst.c:139

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 
33  wc.hInstance = hInstance;
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 
48  APP_NAME,
50  0,
51  0,
54  NULL,
55  NULL,
56  hInstance,
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 }
HGDIOBJ WINAPI GetStockObject(_In_ int)
#define DispatchMessage
Definition: winuser.h:5740
BOOL WINAPI TranslateMessage(_In_ const MSG *)
const CHAR * LPCTSTR
Definition: xmlstorage.h:193
#define DEFAULT_QUALITY
Definition: wingdi.h:435
#define CreateWindow
Definition: winuser.h:5729
#define FF_DONTCARE
Definition: wingdi.h:447
const TCHAR * APP_NAME
Definition: enumwnd.c:15
#define RGB(r, g, b)
Definition: precomp.h:62
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1827
HBRUSH hbrBackground
Definition: enumwnd.c:12
HWND hWnd
Definition: settings.c:17
LRESULT WINAPI MainWndProc(HWND, UINT, WPARAM, LPARAM)
Definition: enumwnd.c:109
int cbClsExtra
Definition: winuser.h:3140
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
#define CS_HREDRAW
Definition: winuser.h:648
LPCSTR lpszMenuName
Definition: winuser.h:3146
#define IDI_APPLICATION
Definition: winuser.h:699
HBRUSH hbrBackground
Definition: winuser.h:3145
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
int cbWndExtra
Definition: winuser.h:3141
HINSTANCE hInstance
Definition: charmap.c:20
#define FALSE
Definition: types.h:117
#define FIXED_PITCH
Definition: wingdi.h:443
#define TA_BASELINE
Definition: wingdi.h:927
#define CLIP_DEFAULT_PRECIS
Definition: wingdi.h:425
HCURSOR hCursor
Definition: winuser.h:3144
#define CW_USEDEFAULT
Definition: winuser.h:225
#define CreateFont
Definition: wingdi.h:4442
smooth NULL
Definition: ftsmooth.c:416
#define GRAY_BRUSH
Definition: wingdi.h:897
#define _ftprintf
Definition: tchar.h:518
#define CS_VREDRAW
Definition: winuser.h:653
#define _T(x)
Definition: vfdio.h:22
#define OUT_DEFAULT_PRECIS
Definition: wingdi.h:414
const TCHAR * CLASS_NAME
Definition: enumwnd.c:16
LPCSTR lpszClassName
Definition: winuser.h:3147
#define LoadCursor
Definition: winuser.h:5787
HFONT tf
Definition: enumwnd.c:13
UINT style
Definition: winuser.h:3138
HINSTANCE hInstance
Definition: winuser.h:3142
HBRUSH WINAPI CreateSolidBrush(_In_ COLORREF)
#define GetMessage
Definition: winuser.h:5765
#define FW_NORMAL
Definition: wingdi.h:372
WNDPROC lpfnWndProc
Definition: winuser.h:3139
#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:5811
#define LoadIcon
Definition: winuser.h:5788
#define ANSI_CHARSET
Definition: wingdi.h:382
HICON hIcon
Definition: winuser.h:3143

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().