ReactOS 0.4.16-dev-1946-g52006dd
closewnd.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  WINDOW_LIST
 

Macros

#define WaitForWindow(hWnd, Func, Seconds)    for (UINT waited = 0; !Func(hWnd) && waited < (Seconds) * 1000; waited += 250) Sleep(250);
 

Typedefs

typedef struct WINDOW_LIST WINDOW_LIST
 
typedef struct WINDOW_LISTPWINDOW_LIST
 

Functions

static VOID FreeWindowList (PWINDOW_LIST pList)
 
static BOOL CALLBACK EnumWindowsProc (HWND hwnd, LPARAM lParam)
 
static VOID GetWindowList (PWINDOW_LIST pList)
 
static VOID GetWindowListForClose (PWINDOW_LIST pList)
 
static HWND FindInWindowList (const WINDOW_LIST &list, HWND hWnd)
 
static VOID CloseNewWindows (PWINDOW_LIST pExisting, PWINDOW_LIST pNew)
 
static HWND FindNewWindow (PWINDOW_LIST List1, PWINDOW_LIST List2)
 
static BOOL CALLBACK CountVisibleWindowsProc (HWND hwnd, LPARAM lParam)
 
static INT GetWindowCount (VOID)
 

Macro Definition Documentation

◆ WaitForWindow

#define WaitForWindow (   hWnd,
  Func,
  Seconds 
)     for (UINT waited = 0; !Func(hWnd) && waited < (Seconds) * 1000; waited += 250) Sleep(250);

Definition at line 10 of file closewnd.h.

Typedef Documentation

◆ PWINDOW_LIST

◆ WINDOW_LIST

Function Documentation

◆ CloseNewWindows()

static VOID CloseNewWindows ( PWINDOW_LIST  pExisting,
PWINDOW_LIST  pNew 
)
inlinestatic

Definition at line 78 of file closewnd.h.

79{
80 for (SIZE_T i = 0; i < pNew->m_chWnds; ++i)
81 {
82 HWND hWnd = pNew->m_phWnds[i];
83 if (!IsWindowVisible(hWnd) || FindInWindowList(*pExisting, hWnd))
84 continue;
85
88 /* If this window is still open, you'll need TerminateProcess(). */
89 }
90}
HWND hWnd
Definition: settings.c:17
static HWND FindInWindowList(const WINDOW_LIST &list, HWND hWnd)
Definition: closewnd.h:68
#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
SIZE_T m_chWnds
Definition: closewnd.h:15
HWND * m_phWnds
Definition: closewnd.h:16
ULONG_PTR SIZE_T
Definition: typedefs.h:80
#define WM_CLOSE
Definition: winuser.h:1649
#define WM_SYSCOMMAND
Definition: winuser.h:1769
BOOL WINAPI PostMessageW(_In_opt_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define SMTO_BLOCK
Definition: winuser.h:1235
LRESULT WINAPI SendMessageTimeoutW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM, _In_ UINT, _In_ UINT, _Out_opt_ PDWORD_PTR)
#define SC_CLOSE
Definition: winuser.h:2628
#define SMTO_ABORTIFHUNG
Definition: winuser.h:1234
BOOL WINAPI IsWindowVisible(_In_ HWND)

Referenced by CloseNotepad(), CloseWindow(), START_TEST(), TEST_DoTestEntry(), TEST_End(), and TEST_ShellExecCmdLine().

◆ CountVisibleWindowsProc()

static BOOL CALLBACK CountVisibleWindowsProc ( HWND  hwnd,
LPARAM  lParam 
)
inlinestatic

Definition at line 126 of file closewnd.h.

127{
128 if (!IsWindowVisible(hwnd))
129 return TRUE;
130
131 *(PINT)lParam += 1;
132 return TRUE;
133}
LPARAM lParam
Definition: combotst.c:139
#define TRUE
Definition: types.h:120
int * PINT
Definition: minwindef.h:150
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023

Referenced by GetWindowCount().

◆ EnumWindowsProc()

static BOOL CALLBACK EnumWindowsProc ( HWND  hwnd,
LPARAM  lParam 
)
inlinestatic

Definition at line 27 of file closewnd.h.

28{
30 return TRUE;
31
33 SIZE_T cb = (pList->m_chWnds + 1) * sizeof(HWND);
34 HWND *phWnds = (HWND *)realloc(pList->m_phWnds, cb);
35 if (!phWnds)
36 return FALSE;
37 phWnds[pList->m_chWnds++] = hwnd;
38 pList->m_phWnds = phWnds;
39 return TRUE;
40}
struct WINDOW_LIST * PWINDOW_LIST
#define realloc
Definition: debug_ros.c:6
#define FALSE
Definition: types.h:117
FxChildList * pList
static HMODULE MODULEINFO DWORD cb
Definition: module.c:33

Referenced by GetWindowList().

◆ FindInWindowList()

static HWND FindInWindowList ( const WINDOW_LIST list,
HWND  hWnd 
)
inlinestatic

Definition at line 68 of file closewnd.h.

69{
70 for (SIZE_T i = 0; i < list.m_chWnds; ++i)
71 {
72 if (list.m_phWnds[i] == hWnd)
73 return hWnd;
74 }
75 return NULL;
76}
Definition: list.h:37

Referenced by CloseNewWindows(), and CloseWindow().

◆ FindNewWindow()

static HWND FindNewWindow ( PWINDOW_LIST  List1,
PWINDOW_LIST  List2 
)
inlinestatic

Definition at line 102 of file closewnd.h.

103{
104 for (SIZE_T i2 = 0; i2 < List2->m_chWnds; ++i2)
105 {
106 HWND hWnd = List2->m_phWnds[i2];
108 continue;
109
110 BOOL bFoundInList1 = FALSE;
111 for (SIZE_T i1 = 0; i1 < List1->m_chWnds; ++i1)
112 {
113 if (hWnd == List1->m_phWnds[i1])
114 {
115 bFoundInList1 = TRUE;
116 break;
117 }
118 }
119
120 if (!bFoundInList1)
121 return hWnd;
122 }
123 return NULL;
124}
unsigned int BOOL
Definition: ntddk_ex.h:94
BOOL WINAPI IsWindowEnabled(_In_ HWND)

Referenced by CloseNotepad().

◆ FreeWindowList()

static VOID FreeWindowList ( PWINDOW_LIST  pList)
inlinestatic

Definition at line 20 of file closewnd.h.

21{
22 free(pList->m_phWnds);
23 pList->m_phWnds = NULL;
24 pList->m_chWnds = 0;
25}
#define free
Definition: debug_ros.c:5

Referenced by CloseNotepad(), GetWindowListForClose(), START_TEST(), TEST_DoTestEntry(), TEST_End(), and TEST_ShellExecCmdLine().

◆ GetWindowCount()

static INT GetWindowCount ( VOID  )
inlinestatic

Definition at line 135 of file closewnd.h.

136{
137 INT nCount = 0;
139 return nCount;
140}
static BOOL CALLBACK CountVisibleWindowsProc(HWND hwnd, LPARAM lParam)
Definition: closewnd.h:126
LONG_PTR LPARAM
Definition: minwindef.h:175
int32_t INT
Definition: typedefs.h:58
BOOL WINAPI EnumWindows(_In_ WNDENUMPROC lpEnumFunc, _In_ LPARAM lParam)

Referenced by TEST_End().

◆ GetWindowList()

static VOID GetWindowList ( PWINDOW_LIST  pList)
inlinestatic

Definition at line 42 of file closewnd.h.

43{
44 pList->m_phWnds = NULL;
45 pList->m_chWnds = 0;
47}
static BOOL CALLBACK EnumWindowsProc(HWND hwnd, LPARAM lParam)
Definition: closewnd.h:27

Referenced by CloseNotepad(), GetWindowListForClose(), START_TEST(), TEST_DoTestEntry(), TEST_End(), TEST_ShellExecCmdLine(), and TEST_Start().

◆ GetWindowListForClose()

static VOID GetWindowListForClose ( PWINDOW_LIST  pList)
inlinestatic

Definition at line 49 of file closewnd.h.

50{
52 pList->m_phWnds = NULL;
53 pList->m_chWnds = 0;
54 for (SIZE_T tries = 5, count; tries--;)
55 {
56 if (tries)
59 Sleep(250);
61 count = list.m_chWnds;
63 if (count == pList->m_chWnds)
64 break;
65 }
66}
static VOID FreeWindowList(PWINDOW_LIST pList)
Definition: closewnd.h:20
static VOID GetWindowList(PWINDOW_LIST pList)
Definition: closewnd.h:42
GLuint GLuint GLsizei count
Definition: gl.h:1545
#define list
Definition: rosglue.h:35
VOID WINAPI DECLSPEC_HOTPATCH Sleep(IN DWORD dwMilliseconds)
Definition: synch.c:790