ReactOS 0.4.15-dev-8145-ga541a46
browsewnd.c File Reference
#include <precomp.h>
Include dependency graph for browsewnd.c:

Go to the source code of this file.

Macros

#define EXE_SEARCH_DIR   L"\\Debug\\testexes\\*"
 
#define IL_MAIN   0
 
#define IL_TEST   1
 
#define HAS_NO_CHILD   0
 
#define HAS_CHILD   1
 

Functions

static INT GetNumberOfExesInFolder (LPWSTR lpFolder)
 
static INT GetListOfTestExes (PMAIN_WND_INFO pInfo)
 
static BOOL NodeHasChild (PMAIN_WND_INFO pInfo, HTREEITEM hItem)
 
static VOID FreeItemTag (PMAIN_WND_INFO pInfo, HTREEITEM hItem)
 
static VOID TraverseTreeView (PMAIN_WND_INFO pInfo, HTREEITEM hItem)
 
static HTREEITEM InsertIntoTreeView (HWND hTreeView, HTREEITEM hRoot, LPWSTR lpLabel, LPARAM Tag, INT Image, INT Child)
 
static PTEST_ITEM BuildTestItemData (LPWSTR lpName, LPWSTR lpRunCmd)
 
static VOID PopulateTreeView (PMAIN_WND_INFO pInfo)
 
static VOID PopulateTestList (PMAIN_WND_INFO pInfo)
 
static BOOL OnInitBrowseDialog (HWND hDlg, LPARAM lParam)
 
BOOL CALLBACK BrowseDlgProc (HWND hDlg, UINT Message, WPARAM wParam, LPARAM lParam)
 

Macro Definition Documentation

◆ EXE_SEARCH_DIR

#define EXE_SEARCH_DIR   L"\\Debug\\testexes\\*"

Definition at line 12 of file browsewnd.c.

◆ HAS_CHILD

#define HAS_CHILD   1

Definition at line 17 of file browsewnd.c.

◆ HAS_NO_CHILD

#define HAS_NO_CHILD   0

Definition at line 16 of file browsewnd.c.

◆ IL_MAIN

#define IL_MAIN   0

Definition at line 13 of file browsewnd.c.

◆ IL_TEST

#define IL_TEST   1

Definition at line 14 of file browsewnd.c.

Function Documentation

◆ BrowseDlgProc()

BOOL CALLBACK BrowseDlgProc ( HWND  hDlg,
UINT  Message,
WPARAM  wParam,
LPARAM  lParam 
)

Definition at line 332 of file browsewnd.c.

336{
337 PMAIN_WND_INFO pInfo;
338
339 /* Get the window context */
340 pInfo = (PMAIN_WND_INFO)GetWindowLongPtr(hDlg,
342 if (pInfo == NULL && Message != WM_INITDIALOG)
343 {
344 goto HandleDefaultMessage;
345 }
346
347 switch(Message)
348 {
349 case WM_INITDIALOG:
350 return OnInitBrowseDialog(hDlg, lParam);
351
352 case WM_COMMAND:
353 {
354 switch (LOWORD(wParam))
355 {
356 case IDOK:
357 {
358 TV_ITEM tvItem;
359
360 tvItem.hItem = TreeView_GetSelection(pInfo->hBrowseTV);
361 tvItem.mask = TVIF_PARAM;
362
363 if (TreeView_GetItem(pInfo->hBrowseTV, &tvItem))
364 {
365 PTEST_ITEM pItem;
366
367 pItem = (PTEST_ITEM)tvItem.lParam;
368 if (pItem)
369 CopyMemory(&pInfo->SelectedTest, pItem, sizeof(TEST_ITEM));
370
371 EndDialog(hDlg,
372 LOWORD(wParam));
373 }
374 else
375 {
376 DisplayMessage(L"Please select an item");
377 }
378
379 return TRUE;
380 }
381
382 case IDCANCEL:
383 {
384 HeapFree(GetProcessHeap(), 0, pInfo->lpExeList);
385 pInfo->lpExeList = NULL;
386
387 EndDialog(hDlg,
388 LOWORD(wParam));
389
390 return TRUE;
391 }
392 }
393
394 break;
395 }
396
397 case WM_DESTROY:
398 {
400
401 TraverseTreeView(pInfo, hItem);
402
403 pInfo->hBrowseDlg = NULL;
404
405 break;
406 }
407
408HandleDefaultMessage:
409 default:
410 return FALSE;
411 }
412
413 return FALSE;
414}
struct _MAIN_WND_INFO * PMAIN_WND_INFO
static VOID TraverseTreeView(PMAIN_WND_INFO pInfo, HTREEITEM hItem)
Definition: browsewnd.c:137
static BOOL OnInitBrowseDialog(HWND hDlg, LPARAM lParam)
Definition: browsewnd.c:313
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define GetProcessHeap()
Definition: compat.h:736
#define HeapFree(x, y, z)
Definition: compat.h:735
static const WCHAR Message[]
Definition: register.c:74
if(dx< 0)
Definition: linetemp.h:194
struct _TEST_ITEM * PTEST_ITEM
#define L(x)
Definition: ntvdm.h:50
#define LOWORD(l)
Definition: pedump.c:82
#define TreeView_GetSelection(hwnd)
Definition: commctrl.h:3473
#define TreeView_GetItem(hwnd, pitem)
Definition: commctrl.h:3490
#define TV_ITEM
Definition: commctrl.h:3300
#define TreeView_GetRoot(hwnd)
Definition: commctrl.h:3475
#define TVIF_PARAM
Definition: commctrl.h:3268
void DisplayMessage(BOOL bConsole, BOOL bSilent, LPCTSTR lpMessage, LPCTSTR lpTitle, UINT uType)
Definition: regsvr32.c:239
HWND hBrowseTV
Definition: precomp.h:26
LPWSTR lpExeList
Definition: precomp.h:37
HWND hBrowseDlg
Definition: precomp.h:25
TEST_ITEM SelectedTest
Definition: precomp.h:40
#define GetWindowLongPtr
Definition: treelist.c:73
#define GWLP_USERDATA
Definition: treelist.c:63
#define CopyMemory
Definition: winbase.h:1710
#define IDCANCEL
Definition: winuser.h:831
#define WM_COMMAND
Definition: winuser.h:1740
#define WM_INITDIALOG
Definition: winuser.h:1739
#define IDOK
Definition: winuser.h:830
#define WM_DESTROY
Definition: winuser.h:1609
BOOL WINAPI EndDialog(_In_ HWND, _In_ INT_PTR)

Referenced by MainDlgProc().

◆ BuildTestItemData()

static PTEST_ITEM BuildTestItemData ( LPWSTR  lpName,
LPWSTR  lpRunCmd 
)
static

Definition at line 208 of file browsewnd.c.

210{
211 PTEST_ITEM pItem;
212
214 0,
215 sizeof(TEST_ITEM));
216 if (pItem)
217 {
218 if (lpName)
219 {
220 wcsncpy(pItem->szName, lpName, MAX_PATH);
221 }
222 if (lpRunCmd)
223 {
224 wcsncpy(pItem->szRunCmd, lpRunCmd, MAX_RUN_CMD);
225 }
226 }
227
228 return pItem;
229}
#define HeapAlloc
Definition: compat.h:733
#define MAX_PATH
Definition: compat.h:34
#define MAX_RUN_CMD
Definition: precomp.h:13
struct _TEST_ITEM TEST_ITEM
_CRTIMP wchar_t *__cdecl wcsncpy(wchar_t *_Dest, const wchar_t *_Source, size_t _Count)
WCHAR szRunCmd[MAX_RUN_CMD]
Definition: precomp.h:18
WCHAR szName[MAX_NAME]
Definition: precomp.h:17
_In_ LPCSTR lpName
Definition: winbase.h:2789

Referenced by PopulateTreeView().

◆ FreeItemTag()

static VOID FreeItemTag ( PMAIN_WND_INFO  pInfo,
HTREEITEM  hItem 
)
static

Definition at line 121 of file browsewnd.c.

123{
124 TV_ITEM tvItem;
125
126 tvItem.hItem = hItem;
127 tvItem.mask = TVIF_PARAM;
128
129 (void)TreeView_GetItem(pInfo->hBrowseTV, &tvItem);
130
132 0,
133 (PTEST_ITEM)tvItem.lParam);
134}
HTREEITEM hItem
Definition: treelist.h:37

Referenced by TraverseTreeView().

◆ GetListOfTestExes()

static INT GetListOfTestExes ( PMAIN_WND_INFO  pInfo)
static

Definition at line 47 of file browsewnd.c.

48{
49 HANDLE hFind;
50 WIN32_FIND_DATAW findFileData;
51 WCHAR szExePath[MAX_PATH];
52 LPWSTR ptr;
53 INT numFiles = 0;
54 INT len;
55
56 len = GetCurrentDirectoryW(MAX_PATH, szExePath);
57 if (!len) return 0;
58
59 wcsncat(szExePath, EXE_SEARCH_DIR, MAX_PATH - (len + 1));
60
61 numFiles = GetNumberOfExesInFolder(szExePath);
62 if (!numFiles) return 0;
63
65 0,
66 numFiles * (MAX_PATH * sizeof(WCHAR)));
67 if (!pInfo->lpExeList)
68 return 0;
69
70 hFind = FindFirstFileW(szExePath,
71 &findFileData);
72 if (hFind == INVALID_HANDLE_VALUE)
73 {
75 HeapFree(GetProcessHeap(), 0, pInfo->lpExeList);
76 return 0;
77 }
78
79 /* remove the glob */
80 ptr = wcschr(szExePath, L'*');
81 if (ptr)
82 *ptr = L'\0';
83
84 /* don't modify our base pointer */
85 ptr = pInfo->lpExeList;
86
87 do
88 {
89 if (!(findFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
90 {
91 /* set the path */
92 wcscpy(ptr, szExePath);
93
94 /* tag the file onto the path */
95 len = MAX_PATH - (wcslen(ptr) + 1);
96 wcsncat(ptr, findFileData.cFileName, len);
97
98 /* move the pointer along by MAX_PATH */
99 ptr += MAX_PATH;
100 }
101 } while (FindNextFile(hFind, &findFileData) != 0);
102
103 return numFiles;
104}
#define EXE_SEARCH_DIR
Definition: browsewnd.c:12
static INT GetNumberOfExesInFolder(LPWSTR lpFolder)
Definition: browsewnd.c:21
#define wcschr
Definition: compat.h:17
#define GetCurrentDirectoryW(x, y)
Definition: compat.h:756
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
HANDLE WINAPI FindFirstFileW(IN LPCWSTR lpFileName, OUT LPWIN32_FIND_DATAW lpFindFileData)
Definition: find.c:320
GLenum GLsizei len
Definition: glext.h:6722
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
VOID DisplayError(DWORD dwError)
Definition: logoff.c:33
static PVOID ptr
Definition: dispmode.c:27
#define FILE_ATTRIBUTE_DIRECTORY
Definition: nt_native.h:705
_CRTIMP wchar_t *__cdecl wcsncat(wchar_t *_Dest, const wchar_t *_Source, size_t _Count)
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
int32_t INT
Definition: typedefs.h:58
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define FindNextFile
Definition: winbase.h:3788
__wchar_t WCHAR
Definition: xmlstorage.h:180
WCHAR * LPWSTR
Definition: xmlstorage.h:184

Referenced by PopulateTestList().

◆ GetNumberOfExesInFolder()

static INT GetNumberOfExesInFolder ( LPWSTR  lpFolder)
static

Definition at line 21 of file browsewnd.c.

22{
23 HANDLE hFind;
24 WIN32_FIND_DATAW findFileData;
25 INT numFiles = 0;
26
27 hFind = FindFirstFileW(lpFolder,
28 &findFileData);
29 if (hFind == INVALID_HANDLE_VALUE)
30 {
32 return 0;
33 }
34
35 do
36 {
37 if (!(findFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
38 {
39 numFiles++;
40 }
41 } while (FindNextFile(hFind, &findFileData) != 0);
42
43 return numFiles;
44}

Referenced by GetListOfTestExes().

◆ InsertIntoTreeView()

static HTREEITEM InsertIntoTreeView ( HWND  hTreeView,
HTREEITEM  hRoot,
LPWSTR  lpLabel,
LPARAM  Tag,
INT  Image,
INT  Child 
)
static

Definition at line 180 of file browsewnd.c.

186{
187 TV_ITEM tvi;
188 TV_INSERTSTRUCT tvins;
189
190 ZeroMemory(&tvi, sizeof(tvi));
191 ZeroMemory(&tvins, sizeof(tvins));
192
194 tvi.pszText = lpLabel;
195 tvi.cchTextMax = lstrlen(lpLabel);
196 tvi.lParam = Tag;
197 tvi.iImage = Image;
198 tvi.iSelectedImage = Image;
199 tvi.cChildren = Child;
200
201 tvins.item = tvi;
202 tvins.hParent = hRoot;
203
204 return TreeView_InsertItem(hTreeView, &tvins);
205}
static HTREEITEM hRoot
Definition: treeview.c:381
#define TVIF_TEXT
Definition: commctrl.h:3266
#define TVIF_IMAGE
Definition: commctrl.h:3267
#define TV_INSERTSTRUCT
Definition: commctrl.h:3377
#define TVIF_CHILDREN
Definition: commctrl.h:3272
#define TreeView_InsertItem(hwnd, lpis)
Definition: commctrl.h:3412
#define TVIF_SELECTEDIMAGE
Definition: commctrl.h:3271
_Must_inspect_result_ _In_ WDFDEVICE _In_ BOOLEAN _In_opt_ PVOID Tag
Definition: wdfdevice.h:4065
_Must_inspect_result_ _In_ WDFDEVICE _In_ WDFDEVICE Child
Definition: wdffdo.h:536
#define ZeroMemory
Definition: winbase.h:1712
#define lstrlen
Definition: winbase.h:3876

Referenced by PopulateTreeView().

◆ NodeHasChild()

static BOOL NodeHasChild ( PMAIN_WND_INFO  pInfo,
HTREEITEM  hItem 
)
static

Definition at line 107 of file browsewnd.c.

109{
110 TV_ITEM tvItem;
111
112 tvItem.hItem = hItem;
113 tvItem.mask = TVIF_CHILDREN;
114
115 (void)TreeView_GetItem(pInfo->hBrowseTV, &tvItem);
116
117 return (tvItem.cChildren == 1);
118}

Referenced by TraverseTreeView().

◆ OnInitBrowseDialog()

static BOOL OnInitBrowseDialog ( HWND  hDlg,
LPARAM  lParam 
)
static

Definition at line 313 of file browsewnd.c.

315{
316 PMAIN_WND_INFO pInfo;
317
318 pInfo = (PMAIN_WND_INFO)lParam;
319
320 pInfo->hBrowseDlg = hDlg;
321
322 SetWindowLongPtr(hDlg,
324 (LONG_PTR)pInfo);
325
326 PopulateTestList(pInfo);
327
328 return TRUE;
329}
static VOID PopulateTestList(PMAIN_WND_INFO pInfo)
Definition: browsewnd.c:303
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
#define SetWindowLongPtr
Definition: treelist.c:70

Referenced by BrowseDlgProc().

◆ PopulateTestList()

static VOID PopulateTestList ( PMAIN_WND_INFO  pInfo)
static

Definition at line 303 of file browsewnd.c.

304{
305 pInfo->numExes = GetListOfTestExes(pInfo);
306 if (pInfo->numExes)
307 {
308 PopulateTreeView(pInfo);
309 }
310}
static VOID PopulateTreeView(PMAIN_WND_INFO pInfo)
Definition: browsewnd.c:232
static INT GetListOfTestExes(PMAIN_WND_INFO pInfo)
Definition: browsewnd.c:47

Referenced by OnInitBrowseDialog().

◆ PopulateTreeView()

static VOID PopulateTreeView ( PMAIN_WND_INFO  pInfo)
static

Definition at line 232 of file browsewnd.c.

233{
235 HIMAGELIST hImgList;
236 PTEST_ITEM pTestItem;
237 LPWSTR lpExePath;
238 LPWSTR lpTestName;
239 INT i;
240
242
244
245 hImgList = InitImageList(IDI_ICON,
246 IDI_TESTS,
247 16,
248 16);
249 if (!hImgList) return;
250
252 hImgList,
254
255 pTestItem = BuildTestItemData(L"Full", L"runall");
256
257 /* insert the root item into the tree */
259 NULL,
260 L"Full",
261 (LPARAM)pTestItem,
262 IL_MAIN,
263 HAS_CHILD);
264
265 for (i = 0; i < pInfo->numExes; i++)
266 {
267 HTREEITEM hParent;
268 LPWSTR lpStr;
269
270 lpExePath = pInfo->lpExeList + (MAX_PATH * i);
271
272 lpTestName = wcsrchr(lpExePath, L'\\');
273 if (lpTestName)
274 {
275 lpTestName++;
276
277 lpStr = wcschr(lpTestName, L'_');
278 if (lpStr)
279 {
280 //FIXME: Query the test name from the exe directly
281
282 pTestItem = BuildTestItemData(lpTestName, lpExePath);
283
284 hParent = InsertIntoTreeView(pInfo->hBrowseTV,
285 hRoot,
286 lpTestName,
287 (LPARAM)pTestItem,
288 IL_TEST,
289 HAS_CHILD);
290 }
291 }
292 }
293
294 if (hRoot)
295 {
297 hRoot,
298 TVE_EXPAND);
299 }
300}
#define IDI_ICON
Definition: resource.h:5
HIMAGELIST InitImageList(UINT StartResource, UINT EndResource, UINT Width, UINT Height, ULONG type)
Definition: misc.c:219
#define HAS_CHILD
Definition: browsewnd.c:17
static PTEST_ITEM BuildTestItemData(LPWSTR lpName, LPWSTR lpRunCmd)
Definition: browsewnd.c:208
static HTREEITEM InsertIntoTreeView(HWND hTreeView, HTREEITEM hRoot, LPWSTR lpLabel, LPARAM Tag, INT Image, INT Child)
Definition: browsewnd.c:180
#define IL_MAIN
Definition: browsewnd.c:13
#define IL_TEST
Definition: browsewnd.c:14
#define wcsrchr
Definition: compat.h:16
#define IDC_TREEVIEW
Definition: resource.h:13
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 IDI_TESTS
Definition: resource.h:7
#define TreeView_DeleteAllItems(hwnd)
Definition: commctrl.h:3417
#define TreeView_Expand(hwnd, hitem, code)
Definition: commctrl.h:3420
#define TVSIL_NORMAL
Definition: commctrl.h:3443
#define TVE_EXPAND
Definition: commctrl.h:3423
#define TreeView_SetImageList(hwnd, himl, iImage)
Definition: commctrl.h:3447
LONG_PTR LPARAM
Definition: windef.h:208
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)

Referenced by PopulateTestList().

◆ TraverseTreeView()

static VOID TraverseTreeView ( PMAIN_WND_INFO  pInfo,
HTREEITEM  hItem 
)
static

Definition at line 137 of file browsewnd.c.

139{
140 while (NodeHasChild(pInfo, hItem))
141 {
142 HTREEITEM hChildItem;
143
144 FreeItemTag(pInfo, hItem);
145
146 hChildItem = TreeView_GetChild(pInfo->hBrowseTV,
147 hItem);
148
149 TraverseTreeView(pInfo,
150 hChildItem);
151
153 hItem);
154 }
155
156 if (hItem)
157 {
158 /* loop the child items and free the tags */
159 while (TRUE)
160 {
161 HTREEITEM hOldItem;
162
163 FreeItemTag(pInfo, hItem);
164 hOldItem = hItem;
166 hItem);
167 if (hItem == NULL)
168 {
169 hItem = hOldItem;
170 break;
171 }
172 }
173
175 hItem);
176 }
177}
static VOID FreeItemTag(PMAIN_WND_INFO pInfo, HTREEITEM hItem)
Definition: browsewnd.c:121
static BOOL NodeHasChild(PMAIN_WND_INFO pInfo, HTREEITEM hItem)
Definition: browsewnd.c:107
#define TreeView_GetChild(hwnd, hitem)
Definition: commctrl.h:3466
#define TreeView_GetParent(hwnd, hitem)
Definition: commctrl.h:3469
#define TreeView_GetNextSibling(hwnd, hitem)
Definition: commctrl.h:3467

Referenced by BrowseDlgProc(), and TraverseTreeView().