ReactOS 0.4.16-dev-336-gb667d82
mainwnd.c
Go to the documentation of this file.
1/*
2 * PROJECT: ReactOS API Test GUI
3 * LICENSE: GPL - See COPYING in the top level directory
4 * FILE:
5 * PURPOSE: main dialog implementation
6 * COPYRIGHT: Copyright 2008 Ged Murphy <gedmurphy@reactos.org>
7 *
8 */
9
10#include <precomp.h>
11#include <io.h>
12
13#define BUFSIZE 4096
14
16
17WCHAR szPipeName[] = L"\\\\.\\pipe\\winetest_pipe";
18
19typedef int (_cdecl *RUNTEST)(char **);
20
23{
24 PMAIN_WND_INFO pInfo;
26 DWORD dwRead;
27 CHAR chBuf[BUFSIZE];
30 INT count;
31
32 pInfo = (PMAIN_WND_INFO)lpParam;
33
36
37 ZeroMemory(&item, sizeof(LVITEMA));
38 item.mask = LVIF_TEXT;
39
40 while (TRUE)
41 {
42 dwRead = 0;
44 chBuf,
45 BUFSIZE,
46 &dwRead,
47 NULL);
48 if(!bSuccess || dwRead == 0)
49 break;
50
51 chBuf[dwRead] = 0;
52
56
57 //item.iItem = ListView_GetItemCount(hList);
58 //item.pszText = chBuf;
59 //SendMessage(hEdit, LVM_INSERTITEMA, 0, (LPARAM)&item);
60 }
61
62 return 0;
63}
64
65
68{
70 STARTUPINFO si;
73
74 //
75 // Set up the security attributes
76 //
77 sa.nLength= sizeof(SECURITY_ATTRIBUTES);
78 sa.lpSecurityDescriptor = NULL;
79 sa.bInheritHandle = TRUE;
80
81 //
82 // Create a pipe for the child process's STDOUT
83 //
84 if (!CreatePipe(&pInfo->hStdOutRd,
85 &pInfo->hStdOutWr,
86 &sa,
87 0))
88 {
89 return FALSE;
90 }
91
92 //
93 // Ensure the read handle to the pipe for STDOUT is not inherited
94 //
97 0))
98 {
99 return FALSE;
100 }
101
102 ZeroMemory(&si, sizeof(STARTUPINFO));
103 si.cb = sizeof(STARTUPINFO);
104 si.hStdError = pInfo->hStdOutWr;
105 si.hStdOutput = pInfo->hStdOutWr;
108
110
112 NULL,
113 NULL,
114 NULL,
115 TRUE,
116 0,//CREATE_SUSPENDED,
117 NULL,
118 NULL,
119 &si,
120 &pi);
121 if (bSuccess)
122 {
123 //
124 // Create thread to handle pipe input from child processes
125 //
127 0,
129 pInfo,
130 0,
131 NULL);
132
134
135 CloseHandle(pi.hProcess);
136 CloseHandle(pi.hThread);
137 }
138
139 return bSuccess;
140}
141
142
143static BOOL
146{
147 PMAIN_WND_INFO pInfo;
148
149 pInfo = (PMAIN_WND_INFO)lParam;
150
151 /* Initialize the main window context */
152 pInfo->hMainWnd = hDlg;
153
154 SetWindowLongPtr(hDlg,
156 (LONG_PTR)pInfo);
157
161 16,
162 16,
163 0);
164 if (pInfo->hSmIcon)
165 {
166 SendMessageW(hDlg,
167 WM_SETICON,
169 (LPARAM)pInfo->hSmIcon);
170 }
171
175 32,
176 32,
177 0);
178 if (pInfo->hBgIcon)
179 {
180 SendMessageW(hDlg,
181 WM_SETICON,
182 ICON_BIG,
183 (LPARAM)pInfo->hBgIcon);
184 }
185
186 return TRUE;
187}
188
189static VOID
191{
192 HWND hRunCmd;
193 WCHAR szTextCmd[MAX_RUN_CMD];
194 INT sel;
195
196 hRunCmd = GetDlgItem(pInfo->hMainWnd, IDC_TESTSELECTION);
197
198 sel = SendMessageW(hRunCmd,
200 0,
201 0);
202 if (sel != CB_ERR)
203 {
204 if (SendMessageW(hRunCmd,
206 sel,
207 (LPARAM)szTextCmd) != CB_ERR)
208 {
209 pInfo->lpCmdLine = (LPWSTR)SendMessage(hRunCmd,
211 0,
212 0);
213 if (pInfo->lpCmdLine)
214 {
215 //
216 // Create a new thread to create the client process
217 // and receive any ouput via stdout
218 //
220 0,
222 pInfo,
223 0,
224 NULL);
225 }
226 }
227 }
228}
229
230static VOID
232{
233 HWND hRunCmd;
234 LPWSTR lpExePath;
235 INT len;
236
237 hRunCmd = GetDlgItem(pInfo->hMainWnd, IDC_TESTSELECTION);
238 if (hRunCmd)
239 {
240 SendMessageW(hRunCmd,
242 0,
243 (LPARAM)pInfo->SelectedTest.szName);
244
245 len = (wcslen(pInfo->SelectedTest.szRunCmd) + 1) * sizeof(WCHAR);
246 lpExePath = HeapAlloc(GetProcessHeap(), 0, len);
247 if (lpExePath)
248 {
249 wcsncpy(lpExePath,
250 pInfo->SelectedTest.szRunCmd,
251 len / sizeof(WCHAR));
252 }
253
254 SendMessageW(hRunCmd,
256 0,
257 (LPARAM)lpExePath);
258 SendMessageW(hRunCmd,
260 0,
261 0);
262 }
263}
264
265static VOID
267{
268 HWND hRunCmd;
269 LPWSTR lpExePath;
270 INT cnt, i;
271
272 hRunCmd = GetDlgItem(pInfo->hMainWnd, IDC_TESTSELECTION);
273
274 cnt = SendMessageW(hRunCmd,
276 0,
277 0);
278 if (cnt != CB_ERR)
279 {
280 for (i = 0; i < cnt; i++)
281 {
282 lpExePath = (LPWSTR)SendMessage(hRunCmd,
284 i,
285 0);
286 if (lpExePath)
287 {
288 HeapFree(GetProcessHeap(), 0, lpExePath);
289 }
290 }
291 }
292}
293
294static BOOL CALLBACK
299{
300 PMAIN_WND_INFO pInfo;
301
302 /* Get the window context */
303 pInfo = (PMAIN_WND_INFO)GetWindowLongPtr(hDlg,
305 if (pInfo == NULL && Message != WM_INITDIALOG)
306 {
307 goto HandleDefaultMessage;
308 }
309
310 switch(Message)
311 {
312 case WM_INITDIALOG:
313 return OnInitMainDialog(hDlg, lParam);
314
315 case WM_COMMAND:
316 {
317 switch(LOWORD(wParam))
318 {
319 case IDC_BROWSE:
320 {
321 INT_PTR ret;
322
325 hDlg,
327 (LPARAM)pInfo);
328 if (ret == IDOK)
329 {
330 AddTestToCombo(pInfo);
331 }
332
333 break;
334 }
335 case IDC_OPTIONS:
338 hDlg,
340 (LPARAM)pInfo);
341 break;
342
343 case IDC_RUN:
344 RunSelectedTest(pInfo);
345 break;
346
347 case IDOK:
348 EndDialog(hDlg, 0);
349 break;
350 }
351 }
352 break;
353
354 case WM_CLOSE:
355 EndDialog(hDlg, 0);
356 break;
357
358 case WM_DESTROY:
359 if (pInfo->hSmIcon)
360 DestroyIcon(pInfo->hSmIcon);
361 if (pInfo->hBgIcon)
362 DestroyIcon(pInfo->hBgIcon);
363
364 FreeTestCmdStrings(pInfo);
365
366 break;
367
368HandleDefaultMessage:
369 default:
370 return FALSE;
371 }
372
373 return FALSE;
374}
375
376
379 HINSTANCE hPrev,
380 LPWSTR Cmd,
381 int iCmd)
382{
384 PMAIN_WND_INFO pInfo;
385 INT Ret = -1;
386
390
392
393 ZeroMemory(&iccx, sizeof(INITCOMMONCONTROLSEX));
394 iccx.dwSize = sizeof(INITCOMMONCONTROLSEX);
395 iccx.dwICC = ICC_TAB_CLASSES;
397
398 pInfo = HeapAlloc(GetProcessHeap(),
399 0,
400 sizeof(MAIN_WND_INFO));
401 if (pInfo)
402 {
405 NULL,
407 (LPARAM)pInfo) == IDOK);
408
410 0,
411 pInfo);
412 }
413
414 return Ret;
415}
static struct sockaddr_in sa
Definition: adnsresfilter.c:69
#define IDC_OPTIONS
#define IDI_ICON
Definition: resource.h:5
#define IDD_OPTIONS
Definition: resource.h:19
struct _MAIN_WND_INFO * PMAIN_WND_INFO
HANDLE WINAPI GetStdHandle(IN DWORD nStdHandle)
Definition: console.c:203
#define IDC_RUN
Definition: resource.h:21
#define IDC_BROWSE
Definition: resource.h:21
BOOL CALLBACK BrowseDlgProc(HWND hDlg, UINT Message, WPARAM wParam, LPARAM lParam)
Definition: browsewnd.c:332
HINSTANCE hInstance
Definition: charmap.c:19
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
BOOL WINAPI InitCommonControlsEx(const INITCOMMONCONTROLSEX *lpInitCtrls)
Definition: commctrl.c:900
#define DLGPROC
Definition: maze.c:62
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define CloseHandle
Definition: compat.h:739
#define GetProcessHeap()
Definition: compat.h:736
struct _SECURITY_ATTRIBUTES SECURITY_ATTRIBUTES
#define ReadFile(a, b, c, d, e)
Definition: compat.h:742
#define HeapAlloc
Definition: compat.h:733
#define HeapFree(x, y, z)
Definition: compat.h:735
#define CALLBACK
Definition: compat.h:35
BOOL WINAPI SetHandleInformation(IN HANDLE hObject, IN DWORD dwMask, IN DWORD dwFlags)
Definition: handle.c:78
BOOL WINAPI DECLSPEC_HOTPATCH CreateProcessW(LPCWSTR lpApplicationName, LPWSTR lpCommandLine, LPSECURITY_ATTRIBUTES lpProcessAttributes, LPSECURITY_ATTRIBUTES lpThreadAttributes, BOOL bInheritHandles, DWORD dwCreationFlags, LPVOID lpEnvironment, LPCWSTR lpCurrentDirectory, LPSTARTUPINFOW lpStartupInfo, LPPROCESS_INFORMATION lpProcessInformation)
Definition: proc.c:4598
HANDLE WINAPI DECLSPEC_HOTPATCH CreateThread(IN LPSECURITY_ATTRIBUTES lpThreadAttributes, IN DWORD dwStackSize, IN LPTHREAD_START_ROUTINE lpStartAddress, IN LPVOID lpParameter, IN DWORD dwCreationFlags, OUT LPDWORD lpThreadId)
Definition: thread.c:137
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31
static const WCHAR Message[]
Definition: register.c:74
static BOOLEAN bSuccess
Definition: drive.cpp:355
#define INFINITE
Definition: serial.h:102
HINSTANCE hInst
Definition: dxdiag.c:13
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLenum GLsizei len
Definition: glext.h:6722
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
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
HWND hList
Definition: livecd.c:10
#define IDC_LIST
Definition: resource.h:93
INT WINAPI wWinMain(HINSTANCE hInst, HINSTANCE hPrev, LPWSTR Cmd, int iCmd)
Definition: mainwnd.c:378
static BOOL CALLBACK MainDlgProc(HWND hDlg, UINT Message, WPARAM wParam, LPARAM lParam)
Definition: mainwnd.c:295
static BOOL OnInitMainDialog(HWND hDlg, LPARAM lParam)
Definition: mainwnd.c:144
static VOID AddTestToCombo(PMAIN_WND_INFO pInfo)
Definition: mainwnd.c:231
DWORD WINAPI CreateClientProcess(PMAIN_WND_INFO pInfo)
Definition: mainwnd.c:67
int(_cdecl * RUNTEST)(char **)
Definition: mainwnd.c:19
WCHAR szPipeName[]
Definition: mainwnd.c:17
DWORD WINAPI PipeReadThread(LPVOID lpParam)
Definition: mainwnd.c:22
static VOID RunSelectedTest(PMAIN_WND_INFO pInfo)
Definition: mainwnd.c:190
static VOID FreeTestCmdStrings(PMAIN_WND_INFO pInfo)
Definition: mainwnd.c:266
#define BUFSIZE
Definition: mainwnd.c:13
#define MAX_RUN_CMD
Definition: precomp.h:13
#define IDD_WINETESTGUI
Definition: resource.h:1
#define IDC_OUTPUT
Definition: resource.h:11
#define IDC_TESTSELECTION
Definition: resource.h:12
#define IDD_TESTBROWSER
Definition: resource.h:2
static refpint_t pi[]
Definition: server.c:96
static ATOM item
Definition: dde.c:856
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
unsigned int UINT
Definition: ndis.h:50
BOOL WINAPI CreatePipe(PHANDLE hReadPipe, PHANDLE hWritePipe, LPSECURITY_ATTRIBUTES lpPipeAttributes, DWORD nSize)
Definition: npipe.c:117
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:325
#define L(x)
Definition: ntvdm.h:50
#define LOWORD(l)
Definition: pedump.c:82
struct tagINITCOMMONCONTROLSEX INITCOMMONCONTROLSEX
#define ICC_TAB_CLASSES
Definition: commctrl.h:61
#define LVIF_TEXT
Definition: commctrl.h:2314
@ Cmd
Definition: sacdrv.h:278
_CRTIMP wchar_t *__cdecl wcsncpy(wchar_t *_Dest, const wchar_t *_Source, size_t _Count)
static HWND hEdit
Definition: autocomplete.c:34
INT_PTR CALLBACK OptionsDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: solitaire.cpp:289
HANDLE hStdOutRd
Definition: precomp.h:29
HICON hBgIcon
Definition: precomp.h:35
HWND hMainWnd
Definition: precomp.h:51
HICON hSmIcon
Definition: precomp.h:34
HANDLE hStdOutWr
Definition: precomp.h:30
TEST_ITEM SelectedTest
Definition: precomp.h:40
HANDLE hPipeThread
Definition: precomp.h:28
LPWSTR lpCmdLine
Definition: precomp.h:31
HANDLE hStdOutput
Definition: winbase.h:872
HANDLE hStdError
Definition: winbase.h:873
DWORD dwFlags
Definition: winbase.h:867
DWORD cb
Definition: winbase.h:856
HANDLE hStdInput
Definition: winbase.h:871
WCHAR szRunCmd[MAX_RUN_CMD]
Definition: precomp.h:18
WCHAR szName[MAX_NAME]
Definition: precomp.h:17
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
#define ICON_BIG
Definition: tnclass.cpp:51
#define ICON_SMALL
Definition: tnclass.cpp:48
#define GetWindowLongPtr
Definition: treelist.c:73
#define SetWindowLongPtr
Definition: treelist.c:70
#define GWLP_USERDATA
Definition: treelist.c:63
int32_t INT_PTR
Definition: typedefs.h:64
int32_t INT
Definition: typedefs.h:58
int ret
#define ZeroMemory
Definition: winbase.h:1737
#define STD_INPUT_HANDLE
Definition: winbase.h:293
STARTUPINFOA STARTUPINFO
Definition: winbase.h:3744
#define HANDLE_FLAG_INHERIT
Definition: winbase.h:290
#define STARTF_USESTDHANDLES
Definition: winbase.h:525
LONG_PTR LPARAM
Definition: windef.h:208
UINT_PTR WPARAM
Definition: windef.h:207
#define WINAPI
Definition: msvc.h:6
#define CB_SETITEMDATA
Definition: winuser.h:1969
#define WM_CLOSE
Definition: winuser.h:1624
#define CB_GETLBTEXT
Definition: winuser.h:1955
#define IMAGE_ICON
Definition: winuser.h:212
#define WM_COMMAND
Definition: winuser.h:1743
#define EM_REPLACESEL
Definition: winuser.h:2009
#define CB_ERR
Definition: winuser.h:2438
HANDLE WINAPI LoadImageW(_In_opt_ HINSTANCE hInst, _In_ LPCWSTR name, _In_ UINT type, _In_ int cx, _In_ int cy, _In_ UINT fuLoad)
Definition: cursoricon.c:2255
#define CB_SETCURSEL
Definition: winuser.h:1964
int WINAPI GetWindowTextLengthA(_In_ HWND)
LRESULT WINAPI SendMessageA(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define WM_INITDIALOG
Definition: winuser.h:1742
#define CB_GETCOUNT
Definition: winuser.h:1945
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define IDOK
Definition: winuser.h:833
#define CB_GETITEMDATA
Definition: winuser.h:1953
#define SendMessage
Definition: winuser.h:5855
#define EM_SETSEL
Definition: winuser.h:2021
#define WM_DESTROY
Definition: winuser.h:1612
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
#define CB_INSERTSTRING
Definition: winuser.h:1960
#define CB_GETCURSEL
Definition: winuser.h:1946
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
INT_PTR WINAPI DialogBoxParamW(_In_opt_ HINSTANCE, _In_ LPCWSTR, _In_opt_ HWND, _In_opt_ DLGPROC, _In_ LPARAM)
BOOL WINAPI EndDialog(_In_ HWND, _In_ INT_PTR)
BOOL WINAPI DestroyIcon(_In_ HICON)
Definition: cursoricon.c:2105
__wchar_t WCHAR
Definition: xmlstorage.h:180
WCHAR * LPWSTR
Definition: xmlstorage.h:184
char CHAR
Definition: xmlstorage.h:175