ReactOS  0.4.14-dev-1007-g90d795b
SetActiveWindow.c
Go to the documentation of this file.
1 /*
2  * PROJECT: ReactOS api tests
3  * LICENSE: GPL - See COPYING in the top level directory
4  * PURPOSE: Test for SetActiveWindow
5  * PROGRAMMERS: Giannis Adamopoulos
6  */
7 
8 #include "precomp.h"
9 
11 
12 /* FIXME: test for HWND_TOP, etc...*/
13 static int get_iwnd(HWND hWnd)
14 {
15  if(hWnd == hWnd1) return 1;
16  else if(hWnd == hWnd2) return 2;
17  else return 0;
18 }
19 
21 {
22  int iwnd = get_iwnd(hWnd);
23 
24  if(message > WM_USER || !iwnd || IsDWmMsg(message) || IseKeyMsg(message))
26 
27  switch(message)
28  {
29  case WM_QUERYNEWPALETTE:
30  {
31  HDC hdc = GetDC(0);
33  ok( bits == 8 , "expected WM_QUERYNEWPALETTE only on 8bpp\n");
34  ReleaseDC(0, hdc);
35  return FALSE;
36  }
37  case WM_IME_SETCONTEXT:
38  case WM_IME_NOTIFY :
39  case WM_GETICON :
40  case WM_GETTEXT:
41  break;
44  {
45  WINDOWPOS* pwp = (WINDOWPOS*)lParam;
46  ok(wParam==0,"expected wParam=0\n");
48  break;
49  }
50  default:
51  RECORD_MESSAGE(iwnd, message, SENT, 0,0);
52  }
54 }
55 
56 static void FlushMessages()
57 {
58  MSG msg;
59 
60  while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE ))
61  {
62  int iwnd = get_iwnd(msg.hwnd);
63  if(!(msg.message > WM_USER || !iwnd || IsDWmMsg(msg.message) || IseKeyMsg(msg.message)))
64  RECORD_MESSAGE(iwnd, msg.message, POST,0,0);
66  }
67 }
68 
69 static void create_test_windows()
70 {
71  RegisterSimpleClass(OwnerTestProc, L"ownertest");
72  hWnd1 = CreateWindowW(L"ownertest", L"ownertest", WS_OVERLAPPEDWINDOW,
73  20, 20, 300, 300, NULL, NULL, 0, NULL);
74 
75  hWnd2 = CreateWindowW(L"ownertest", L"ownertest", WS_OVERLAPPEDWINDOW,
76  200, 200, 300, 300, NULL, NULL, 0, NULL);
77 }
78 
79 static void set_default_zorder()
80 {
83 
84  FlushMessages();
85  EMPTY_CACHE();
86 }
87 
88 static void destroy_test_window()
89 {
92  UnregisterClassW(L"testClass", 0);
93 }
94 
96  {2,WM_NCACTIVATE},
97  {2,WM_ACTIVATE},
100  {1,WM_NCACTIVATE},
101  {1,WM_ACTIVATE},
102  {2,WM_KILLFOCUS},
103  {1,WM_SETFOCUS},
104  {0,0}};
105 
107  {1,WM_NCACTIVATE},
108  {1,WM_ACTIVATE},
111  {2,WM_NCACTIVATE},
112  {2,WM_ACTIVATE},
113  {1,WM_KILLFOCUS},
114  {2,WM_SETFOCUS},
115  {0,0}};
116 
118 {
119  SetCursorPos(0,0);
120 
123 
125  FlushMessages();
127 
129  FlushMessages();
131 
133 }
134 
136 {
137  Test_msg_simple();
138 }
#define BITSPIXEL
Definition: wingdi.h:719
#define WM_IME_NOTIFY
Definition: winuser.h:1812
LRESULT WINAPI DispatchMessageA(_In_ const MSG *)
Definition: tftpd.h:59
#define PeekMessage
Definition: winuser.h:5805
BOOL WINAPI UnregisterClassW(_In_ LPCWSTR, HINSTANCE)
Definition: msgtrace.h:14
HDC WINAPI GetDC(_In_opt_ HWND)
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1827
#define WM_GETTEXT
Definition: winuser.h:1600
static HDC
Definition: imagelist.c:92
#define CALLBACK
Definition: compat.h:27
static void create_test_windows()
HWND hWnd
Definition: settings.c:17
HWND hwndInsertAfter
Definition: winuser.h:3564
UINT_PTR WPARAM
Definition: windef.h:207
BOOL WINAPI DestroyWindow(_In_ HWND)
#define CreateWindowW(a, b, c, d, e, f, g, h, i, j, k)
Definition: winuser.h:4291
GLenum GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * bits
Definition: glext.h:10929
WPARAM wParam
Definition: combotst.c:138
LRESULT CALLBACK OwnerTestProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
static BOOL IseKeyMsg(UINT msg)
Definition: msgtrace.h:52
static void destroy_test_window()
HWND WINAPI SetActiveWindow(_In_ HWND)
#define WM_NCACTIVATE
Definition: winuser.h:1670
HWND hWnd2
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
HWND hWnd1
smooth NULL
Definition: ftsmooth.c:416
LONG_PTR LPARAM
Definition: windef.h:208
static int get_iwnd(HWND hWnd)
UINT flags
Definition: winuser.h:3569
#define DefWindowProc
Definition: ros2win.h:31
static __inline ATOM RegisterSimpleClass(WNDPROC lpfnWndProc, LPCWSTR lpszClassName)
#define WM_QUERYNEWPALETTE
Definition: winuser.h:1860
void Test_msg_simple()
static void set_default_zorder()
#define WM_KILLFOCUS
Definition: winuser.h:1596
#define COMPARE_CACHE(msg_chain)
Definition: msgtrace.h:57
#define WM_IME_SETCONTEXT
Definition: winuser.h:1811
#define WM_WINDOWPOSCHANGING
Definition: winuser.h:1643
BOOL WINAPI SetCursorPos(_In_ int, _In_ int)
Definition: cursoricon.c:2627
Definition: msgtrace.h:7
static void FlushMessages()
static const WCHAR L[]
Definition: oid.c:1250
HDC hdc
Definition: main.c:9
int WINAPI GetDeviceCaps(_In_opt_ HDC, _In_ int)
#define EMPTY_CACHE()
Definition: msgtrace.h:59
START_TEST(SetActiveWindow)
#define WM_USER
Definition: winuser.h:1877
#define SWP_NOSIZE
Definition: winuser.h:1230
static BOOL IsDWmMsg(UINT msg)
Definition: msgtrace.h:39
#define WM_ACTIVATE
Definition: winuser.h:1594
#define ok(value,...)
Definition: atltest.h:57
MSG_ENTRY activate2to1_chain[]
unsigned int UINT
Definition: ndis.h:50
#define SWP_SHOWWINDOW
Definition: winuser.h:1233
Definition: msgtrace.h:6
MSG_ENTRY activate1to2_chain[]
#define WM_WINDOWPOSCHANGED
Definition: winuser.h:1644
#define msg(x)
Definition: auth_time.c:54
#define SWP_NOREPOSITION
Definition: winuser.h:1235
#define RECORD_MESSAGE(...)
Definition: msgtrace.h:60
#define WS_OVERLAPPEDWINDOW
Definition: pedump.c:637
#define SWP_NOCLIENTMOVE
Definition: msg.h:30
#define SWP_NOMOVE
Definition: winuser.h:1229
BOOL WINAPI SetWindowPos(_In_ HWND, _In_opt_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ UINT)
#define PM_REMOVE
Definition: winuser.h:1182
#define WM_SETFOCUS
Definition: winuser.h:1595
LONG_PTR LRESULT
Definition: windef.h:209
#define SWP_NOCLIENTSIZE
Definition: msg.h:29
LPARAM lParam
Definition: combotst.c:139