ReactOS 0.4.16-dev-737-g3368adc
closewnd.cpp
Go to the documentation of this file.
1/*
2 * PROJECT: ReactOS API tests
3 * LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+)
4 * PURPOSE: Close windows after tests
5 * COPYRIGHT: Copyright 2024 Katayama Hirofumi MZ (katayama.hirofumi.mz@gmail.com)
6 */
7
8#include "shelltest.h"
9#include "closewnd.h"
10
12{
13 free(pList->m_phWnds);
14 pList->m_phWnds = NULL;
15 pList->m_chWnds = 0;
16}
17
19{
21 return TRUE;
22
24 SIZE_T cb = (pList->m_chWnds + 1) * sizeof(HWND);
25 HWND *phWnds = (HWND *)realloc(pList->m_phWnds, cb);
26 if (!phWnds)
27 return FALSE;
28 phWnds[pList->m_chWnds++] = hwnd;
29 pList->m_phWnds = phWnds;
30 return TRUE;
31}
32
34{
35 pList->m_phWnds = NULL;
36 pList->m_chWnds = 0;
38}
39
41{
42 for (UINT tries = 5; tries--;)
43 {
44 if (tries)
47 Sleep(500);
50 SIZE_T count = list.m_chWnds;
52 if (count == pList->m_chWnds)
53 break;
54 }
55}
56
58{
59 for (SIZE_T i = 0; i < list.m_chWnds; ++i)
60 {
61 if (list.m_phWnds[i] == hWnd)
62 return hWnd;
63 }
64 return NULL;
65}
66
68{
69 for (SIZE_T i2 = 0; i2 < List2->m_chWnds; ++i2)
70 {
71 HWND hWnd = List2->m_phWnds[i2];
73 continue;
74
75 BOOL bFoundInList1 = FALSE;
76 for (SIZE_T i1 = 0; i1 < List1->m_chWnds; ++i1)
77 {
78 if (hWnd == List1->m_phWnds[i1])
79 {
80 bFoundInList1 = TRUE;
81 break;
82 }
83 }
84
85 if (!bFoundInList1)
86 return hWnd;
87 }
88 return NULL;
89}
90
91static void WaitForForegroundWindow(HWND hWnd, UINT wait = 250)
92{
93 for (UINT waited = 0, interval = 50; waited < wait; waited += interval)
94 {
96 return;
98 }
99}
100
102{
103 for (SIZE_T i = 0; i < List2->m_chWnds; ++i)
104 {
105 HWND hWnd = List2->m_phWnds[i];
106 if (!IsWindow(hWnd) || FindInWindowList(*List1, hWnd))
107 continue;
108
111
113 {
116 }
117 }
118}
HWND hWnd
Definition: settings.c:17
Definition: list.h:37
static BOOL CALLBACK EnumWindowsProc(HWND hwnd, LPARAM lParam)
Definition: closewnd.cpp:18
void CloseNewWindows(PWINDOW_LIST List1, PWINDOW_LIST List2)
Definition: closewnd.cpp:101
void GetWindowList(PWINDOW_LIST pList)
Definition: closewnd.cpp:33
HWND FindNewWindow(PWINDOW_LIST List1, PWINDOW_LIST List2)
Definition: closewnd.cpp:67
static void WaitForForegroundWindow(HWND hWnd, UINT wait=250)
Definition: closewnd.cpp:91
static HWND FindInWindowList(const WINDOW_LIST &list, HWND hWnd)
Definition: closewnd.cpp:57
void GetWindowListForClose(PWINDOW_LIST pList)
Definition: closewnd.cpp:40
void FreeWindowList(PWINDOW_LIST pList)
Definition: closewnd.cpp:11
struct WINDOW_LIST * PWINDOW_LIST
LPARAM lParam
Definition: combotst.c:139
#define realloc
Definition: debug_ros.c:6
#define free
Definition: debug_ros.c:5
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define CALLBACK
Definition: compat.h:35
unsigned int BOOL
Definition: ntddk_ex.h:94
FxChildList * pList
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLuint64EXT * result
Definition: glext.h:11304
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
static HMODULE MODULEINFO DWORD cb
Definition: module.c:33
unsigned int UINT
Definition: ndis.h:50
#define list
Definition: rosglue.h:35
SIZE_T m_chWnds
Definition: closewnd.h:12
HWND * m_phWnds
Definition: closewnd.h:13
VOID WINAPI DECLSPEC_HOTPATCH Sleep(IN DWORD dwMilliseconds)
Definition: synch.c:790
uint32_t DWORD_PTR
Definition: typedefs.h:65
ULONG_PTR SIZE_T
Definition: typedefs.h:80
VOID WINAPI SwitchToThisWindow(HWND hwnd, BOOL fAltTab)
Definition: window.c:82
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023
LONG_PTR LPARAM
Definition: windef.h:208
BOOL WINAPI IsWindow(_In_opt_ HWND)
#define WM_SYSCOMMAND
Definition: winuser.h:1744
HWND WINAPI GetForegroundWindow(void)
Definition: ntwrapper.h:392
BOOL WINAPI PostMessageW(_In_opt_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
LRESULT WINAPI SendMessageTimeoutW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM, _In_ UINT, _In_ UINT, _Out_opt_ PDWORD_PTR)
BOOL WINAPI EnumWindows(_In_ WNDENUMPROC lpEnumFunc, _In_ LPARAM lParam)
#define SC_CLOSE
Definition: winuser.h:2595
BOOL WINAPI IsWindowEnabled(_In_ HWND)
BOOL WINAPI IsWindowVisible(_In_ HWND)