ReactOS  0.4.13-dev-544-gede3fdd
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)
GLuint GLfloat * val
Definition: glext.h:7180
DWORD exp
Definition: msg.c:15681
static int get_iwnd(_In_ HWND hWnd, _In_ BOOL set)
Definition: SetParent.c:24

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
HANDLE HWND
Definition: compat.h:13
LPARAM lParam
Definition: combotst.c:139

Referenced by IntEnumFontFamilies(), LdrEnumerateLoadedModules(), SndMixerEnumConnections(), SndMixerEnumLines(), SndMixerEnumProducts(), WndProc(), WrapEnumFontFamiliesA(), WrapEnumFontFamiliesExA(), WrapEnumFontFamiliesExW(), and WrapEnumFontFamiliesW().

◆ 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 }
HWND hWnd
Definition: settings.c:17
static HWND hWndList[5+1]
Definition: SetParent.c:10
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
#define ok(value,...)
smooth NULL
Definition: ftsmooth.c:416
static const int hWndCount
Definition: SetParent.c:11
Definition: _set.h:46

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 
145 trace("\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);
151  DispatchMessageA( &msg );
152  }
153 trace("\n");
154  TRACE_CACHE();
155 trace("\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 
176 trace("\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);
182  DispatchMessageA( &msg );
183  }
184 trace("\n");
185  TRACE_CACHE();
186  }
#define trace(...)
Definition: kmt_test.h:217
LRESULT WINAPI DispatchMessageA(_In_ const MSG *)
#define PeekMessage
Definition: winuser.h:5696
BOOL WINAPI IsWindow(_In_opt_ HWND)
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1827
HWND hWnd
Definition: settings.c:17
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
#define WS_CHILD
Definition: pedump.c:617
static HWND hWndList[5+1]
Definition: SetParent.c:10
BOOL WINAPI DestroyWindow(_In_ HWND)
static DWORD dwThreadId
Definition: SetParent.c:12
static BOOL IseKeyMsg(UINT msg)
Definition: msgtrace.h:52
#define ok(value,...)
#define ok_hwnd(val, exp)
Definition: SetParent.c:14
smooth NULL
Definition: ftsmooth.c:416
DWORD WINAPI GetCurrentThreadId(VOID)
Definition: thread.c:420
static __inline ATOM RegisterSimpleClass(WNDPROC lpfnWndProc, LPCWSTR lpszClassName)
BOOL WINAPI SetCursorPos(_In_ int, _In_ int)
Definition: cursoricon.c:2627
Definition: msgtrace.h:7
static const WCHAR L[]
Definition: oid.c:1250
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 WM_USER
Definition: winuser.h:1856
static BOOL IsDWmMsg(UINT msg)
Definition: msgtrace.h:39
HWND WINAPI GetParent(_In_ HWND)
#define TRACE_CACHE()
Definition: msgtrace.h:58
#define msg(x)
Definition: auth_time.c:54
#define RECORD_MESSAGE(...)
Definition: msgtrace.h:60
#define PM_REMOVE
Definition: winuser.h:1182
static LRESULT CALLBACK WndProc(_In_ HWND hWnd, _In_ UINT message, _In_ WPARAM wParam, _In_ LPARAM lParam)
Definition: SetParent.c:64
static int get_iwnd(_In_ HWND hWnd, _In_ BOOL set)
Definition: SetParent.c:24

◆ 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 }
BOOL WINAPI EnumChildWindows(_In_opt_ HWND, _In_ WNDENUMPROC, _In_ LPARAM)
Definition: tftpd.h:59
#define TRUE
Definition: types.h:120
HWND WINAPI SetParent(_In_ HWND, _In_opt_ HWND)
HWND hWnd
Definition: settings.c:17
BOOL WINAPI EnumThreadWindows(_In_ DWORD, _In_ WNDENUMPROC, _In_ LPARAM)
static HWND hWndList[5+1]
Definition: SetParent.c:10
WPARAM wParam
Definition: combotst.c:138
LRESULT WINAPI DefWindowProcW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
static DWORD dwThreadId
Definition: SetParent.c:12
static BOOL IseKeyMsg(UINT msg)
Definition: msgtrace.h:52
#define ok(value,...)
#define ok_hwnd(val, exp)
Definition: SetParent.c:14
smooth NULL
Definition: ftsmooth.c:416
LONG_PTR LPARAM
Definition: windef.h:208
DWORD WINAPI GetCurrentThreadId(VOID)
Definition: thread.c:420
#define WM_DESTROY
Definition: winuser.h:1591
#define WM_USER
Definition: winuser.h:1856
static BOOL IsDWmMsg(UINT msg)
Definition: msgtrace.h:39
HWND WINAPI GetParent(_In_ HWND)
Definition: msgtrace.h:6
#define RECORD_MESSAGE(...)
Definition: msgtrace.h:60
static BOOL CALLBACK EnumProc(_In_ HWND hWnd, _In_ LPARAM lParam)
Definition: SetParent.c:53
LPARAM lParam
Definition: combotst.c:139
static int get_iwnd(_In_ HWND hWnd, _In_ BOOL set)
Definition: SetParent.c:24

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