ReactOS 0.4.15-dev-7136-g77ab709
SetParent.c File Reference
#include "precomp.h"
Include dependency graph for SetParent.c:

Go to the source code of this file.

Macros

#define ok_hwnd(val, exp)
 

Functions

static int get_iwnd (_In_ HWND hWnd, _In_ BOOL set)
 
static BOOL CALLBACK EnumProc (_In_ HWND hWnd, _In_ LPARAM lParam)
 
static LRESULT CALLBACK WndProc (_In_ HWND hWnd, _In_ UINT message, _In_ WPARAM wParam, _In_ LPARAM lParam)
 
 START_TEST (SetParent)
 

Variables

static HWND hWndList [5+1]
 
static const int hWndCount = sizeof(hWndList) / sizeof(hWndList[0]) - 1
 
static DWORD dwThreadId
 

Macro Definition Documentation

◆ ok_hwnd

#define ok_hwnd (   val,
  exp 
)
Value:
do \
{ \
HWND _val = (val), _exp = (exp); \
int _ival = get_iwnd(_val, FALSE); \
int _iexp = get_iwnd(_exp, FALSE); \
ok(_val == _exp, #val " = %p (%d), expected %p (%d)\n", _val, _ival, _exp, _iexp); \
} while (0)
static int get_iwnd(_In_ HWND hWnd, _In_ BOOL set)
Definition: SetParent.c:24
#define FALSE
Definition: types.h:117
GLuint GLfloat * val
Definition: glext.h:7180
DWORD exp
Definition: msg.c:16058

Definition at line 14 of file SetParent.c.

Function Documentation

◆ EnumProc()

static BOOL CALLBACK EnumProc ( _In_ HWND  hWnd,
_In_ LPARAM  lParam 
)
static

Definition at line 53 of file SetParent.c.

56{
57 HWND hLookingFor = (HWND)lParam;
58 return hWnd != hLookingFor;
59}
HWND hWnd
Definition: settings.c:17
LPARAM lParam
Definition: combotst.c:139
HANDLE HWND
Definition: compat.h:19

Referenced by WndProc().

◆ get_iwnd()

static int get_iwnd ( _In_ HWND  hWnd,
_In_ BOOL  set 
)
static

Definition at line 24 of file SetParent.c.

27{
28 int i;
29 if (!hWnd)
30 return 0;
31 for (i = 1; i <= hWndCount; i++)
32 {
33 if (hWndList[i] == hWnd)
34 return i;
35 }
36 if (!set)
37 return 0;
38 for (i = 1; i <= hWndCount; i++)
39 {
40 if (hWndList[i] == NULL)
41 {
42 hWndList[i] = hWnd;
43 return i;
44 }
45 }
46 ok(0, "Too many windows!\n");
47 return 0;
48}
static HWND hWndList[5+1]
Definition: SetParent.c:10
static const int hWndCount
Definition: SetParent.c:11
#define ok(value,...)
Definition: atltest.h:57
Definition: _set.h:50
#define NULL
Definition: types.h:112
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248

Referenced by START_TEST(), and WndProc().

◆ START_TEST()

START_TEST ( SetParent  )

Definition at line 114 of file SetParent.c.

115{
116 HWND hWnd;
117 MSG msg;
118
119 SetCursorPos(0,0);
120
123 RegisterSimpleClass(WndProc, L"CreateTest");
124
125 hWnd = CreateWindowExW(0, L"CreateTest", NULL, 0, 10, 10, 20, 20, NULL, NULL, 0, NULL);
126 ok(hWnd != NULL, "CreateWindow failed\n");
127 ok(hWnd == hWndList[1], "Got %p, expected %p\n", hWnd, hWndList[1]);
128
129 hWnd = CreateWindowExW(0, L"CreateTest", NULL, 0, 40, 10, 20, 20, NULL, NULL, 0, NULL);
130 ok(hWnd != NULL, "CreateWindow failed\n");
131 ok(hWnd == hWndList[2], "Got %p, expected %p\n", hWnd, hWndList[2]);
132
133 hWnd = CreateWindowExW(0, L"CreateTest", NULL, WS_CHILD, 60, 10, 20, 20, hWndList[1], NULL, 0, NULL);
134 ok(hWnd != NULL, "CreateWindow failed\n");
135 ok(hWnd == hWndList[3], "Got %p, expected %p\n", hWnd, hWndList[3]);
136
137 hWnd = CreateWindowExW(0, L"CreateTest", NULL, WS_CHILD, 80, 10, 20, 20, hWndList[1], NULL, 0, NULL);
138 ok(hWnd != NULL, "CreateWindow failed\n");
139 ok(hWnd == hWndList[4], "Got %p, expected %p\n", hWnd, hWndList[4]);
140
141 hWnd = CreateWindowExW(0, L"CreateTest", NULL, WS_CHILD, 60, 10, 20, 20, hWndList[2], NULL, 0, NULL);
142 ok(hWnd != NULL, "CreateWindow failed\n");
143 ok(hWnd == hWndList[5], "Got %p, expected %p\n", hWnd, hWndList[5]);
144
145trace("\n");
146 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE ))
147 {
148 int iwnd = get_iwnd(msg.hwnd, FALSE);
149 if(!(msg.message > WM_USER || IsDWmMsg(msg.message) || IseKeyMsg(msg.message)))
150 RECORD_MESSAGE(iwnd, msg.message, POST, 0, 0);
152 }
153trace("\n");
154 TRACE_CACHE();
155trace("\n");
156
162
164 ok(!IsWindow(hWndList[1]), "\n");
165 ok( IsWindow(hWndList[2]), "\n");
166 ok(!IsWindow(hWndList[3]), "\n");
167 ok( IsWindow(hWndList[4]), "\n");
168 ok(!IsWindow(hWndList[5]), "\n");
169
175
176trace("\n");
177 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE ))
178 {
179 int iwnd = get_iwnd(msg.hwnd, FALSE);
180 if(!(msg.message > WM_USER || IsDWmMsg(msg.message) || IseKeyMsg(msg.message)))
181 RECORD_MESSAGE(iwnd, msg.message, POST, 0, 0);
183 }
184trace("\n");
185 TRACE_CACHE();
186 }
static LRESULT CALLBACK WndProc(_In_ HWND hWnd, _In_ UINT message, _In_ WPARAM wParam, _In_ LPARAM lParam)
Definition: SetParent.c:64
static DWORD dwThreadId
Definition: SetParent.c:12
#define ok_hwnd(val, exp)
Definition: SetParent.c:14
#define trace
Definition: atltest.h:70
#define msg(x)
Definition: auth_time.c:54
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
static BOOL IsDWmMsg(UINT msg)
Definition: msgtrace.h:39
#define RECORD_MESSAGE(...)
Definition: msgtrace.h:60
#define TRACE_CACHE()
Definition: msgtrace.h:58
@ POST
Definition: msgtrace.h:7
static BOOL IseKeyMsg(UINT msg)
Definition: msgtrace.h:52
#define L(x)
Definition: ntvdm.h:50
#define WS_CHILD
Definition: pedump.c:617
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1829
static __inline ATOM RegisterSimpleClass(WNDPROC lpfnWndProc, LPCWSTR lpszClassName)
DWORD WINAPI GetCurrentThreadId(void)
Definition: thread.c:459
LRESULT WINAPI DispatchMessageA(_In_ const MSG *)
BOOL WINAPI IsWindow(_In_opt_ HWND)
BOOL WINAPI SetCursorPos(_In_ int, _In_ int)
Definition: cursoricon.c:2631
HWND WINAPI CreateWindowExW(_In_ DWORD dwExStyle, _In_opt_ LPCWSTR lpClassName, _In_opt_ LPCWSTR lpWindowName, _In_ DWORD dwStyle, _In_ int X, _In_ int Y, _In_ int nWidth, _In_ int nHeight, _In_opt_ HWND hWndParent, _In_opt_ HMENU hMenu, _In_opt_ HINSTANCE hInstance, _In_opt_ LPVOID lpParam)
#define PM_REMOVE
Definition: winuser.h:1195
#define PeekMessage
Definition: winuser.h:5829
HWND WINAPI GetParent(_In_ HWND)
#define WM_USER
Definition: winuser.h:1894
BOOL WINAPI DestroyWindow(_In_ HWND)

◆ WndProc()

static LRESULT CALLBACK WndProc ( _In_ HWND  hWnd,
_In_ UINT  message,
_In_ WPARAM  wParam,
_In_ LPARAM  lParam 
)
static

Definition at line 64 of file SetParent.c.

69{
70 HWND hTest;
71 int iwnd = get_iwnd(hWnd, TRUE);
72
73 ok(GetCurrentThreadId() == dwThreadId, "Thread 0x%lx instead of 0x%lx\n", GetCurrentThreadId(), dwThreadId);
76
78
79 switch(message)
80 {
81 case WM_DESTROY:
82 if (GetParent(hWnd))
83 {
84 /* child window */
85 ok(EnumThreadWindows(dwThreadId, EnumProc, (LPARAM)hWnd), "Child window %p (%d) enumerated\n", hWnd, iwnd);
86 ok(!EnumChildWindows(GetParent(hWnd), EnumProc, (LPARAM)hWnd), "Child window %p (%d) not enumerated\n", hWnd, iwnd);
87 ok(!EnumThreadWindows(dwThreadId, EnumProc, (LPARAM)GetParent(hWnd)), "Parent window of %p (%d) not enumerated\n", hWnd, iwnd);
88 }
89 else
90 {
91 /* top-level window */
92 ok(!EnumThreadWindows(dwThreadId, EnumProc, (LPARAM)hWnd), "Window %p (%d) not enumerated in WM_DESTROY\n", hWnd, iwnd);
93 }
94 if (hWnd == hWndList[3])
95 {
96 hTest = SetParent(hWndList[4], hWndList[2]);
97 ok_hwnd(hTest, hWndList[1]);
98 hTest = SetParent(hWndList[5], hWndList[1]);
99 ok_hwnd(hTest, hWndList[2]);
100
106 }
107 break;
108 }
109
111}
static BOOL CALLBACK EnumProc(_In_ HWND hWnd, _In_ LPARAM lParam)
Definition: SetParent.c:53
WPARAM wParam
Definition: combotst.c:138
#define TRUE
Definition: types.h:120
@ SENT
Definition: msgtrace.h:6
Definition: tftpd.h:60
LONG_PTR LPARAM
Definition: windef.h:208
LRESULT WINAPI DefWindowProcW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
HWND WINAPI SetParent(_In_ HWND, _In_opt_ HWND)
BOOL WINAPI EnumChildWindows(_In_opt_ HWND, _In_ WNDENUMPROC, _In_ LPARAM)
#define WM_DESTROY
Definition: winuser.h:1608
BOOL WINAPI EnumThreadWindows(_In_ DWORD, _In_ WNDENUMPROC, _In_ LPARAM)

Referenced by START_TEST().

Variable Documentation

◆ dwThreadId

DWORD dwThreadId
static

Definition at line 12 of file SetParent.c.

Referenced by START_TEST(), and WndProc().

◆ hWndCount

const int hWndCount = sizeof(hWndList) / sizeof(hWndList[0]) - 1
static

Definition at line 11 of file SetParent.c.

Referenced by get_iwnd().

◆ hWndList