ReactOS 0.4.16-dev-91-g764881a
dxdiag.c
Go to the documentation of this file.
1/*
2 * PROJECT: ReactX Diagnosis Application
3 * LICENSE: LGPL - See COPYING in the top level directory
4 * FILE: base/applications/dxdiag/dxdiag.c
5 * PURPOSE: ReactX diagnosis application entry
6 * COPYRIGHT: Copyright 2008 Johannes Anderwald
7 *
8 */
9
10#include "precomp.h"
11
12/* globals */
15
17// Taken from WinSpy++ 1.7
18// http://www.catch22.net/software/winspy
19// Copyright (c) 2002 by J Brown
20//
21
22//
23// Copied from uxtheme.h
24// If you have this new header, then delete these and
25// #include <uxtheme.h> instead!
26//
27#define ETDT_DISABLE 0x00000001
28#define ETDT_ENABLE 0x00000002
29#define ETDT_USETABTEXTURE 0x00000004
30#define ETDT_ENABLETAB (ETDT_ENABLE | ETDT_USETABTEXTURE)
31
32//
34
35//
36// Try to call EnableThemeDialogTexture, if uxtheme.dll is present
37//
39{
40 HMODULE hUXTheme;
42
43 hUXTheme = LoadLibraryA("uxtheme.dll");
44
45 if(hUXTheme)
46 {
48 (ETDTProc)GetProcAddress(hUXTheme, "EnableThemeDialogTexture");
49
51 {
53
54 FreeLibrary(hUXTheme);
55 return TRUE;
56 }
57 else
58 {
59 // Failed to locate API!
60 FreeLibrary(hUXTheme);
61 return FALSE;
62 }
63 }
64 else
65 {
66 // Not running under XP? Just fail gracefully
67 return FALSE;
68 }
69}
70
71//---------------------------------------------------------------
72VOID
74{
75 UINT Index;
76
77 /* destroy default dialogs */
78 for(Index = 0; Index < sizeof(pContext->hDialogs) / sizeof(HWND); Index++)
79 {
80 if (pContext->hDialogs[Index])
81 DestroyWindow(pContext->hDialogs[Index]);
82 }
83
84 /* destroy display dialogs */
85 for(Index = 0; Index < pContext->NumDisplayAdapter; Index++)
86 {
87 if (pContext->hDisplayWnd[Index])
89 }
90
91 /* destroy audio dialogs */
92 for(Index = 0; Index < pContext->NumSoundAdapter; Index++)
93 {
94 if (pContext->hSoundWnd[Index])
95 DestroyWindow(pContext->hSoundWnd[Index]);
96 }
97
98}
99
100//---------------------------------------------------------------
101VOID
103{
104 WCHAR szName[100];
106
107 /* setup item info */
108 memset(&item, 0, sizeof(TCITEMW));
109 item.mask = TCIF_TEXT;
110
111 /* load item name */
112 if (!HIWORD(uId))
113 {
114 szName[0] = L'\0';
115 if (!LoadStringW(hInst, LOWORD(uId), szName, 100))
116 return;
117 szName[99] = L'\0';
118 item.pszText = szName;
119 }
120 else
121 {
122 item.pszText = uId;
123 }
124
125
127}
128
129VOID
131{
132 INT Index;
133 INT CurSel;
134
135 /* retrieve new page */
137 if (CurSel < 0 || CurSel > pContext->NumDisplayAdapter + pContext->NumSoundAdapter + 5)
138 return;
139
140 /* hide all windows */
141 for(Index = 0; Index < 5; Index++)
142 ShowWindow(pContext->hDialogs[Index], SW_HIDE);
143
144 for(Index = 0; Index < pContext->NumDisplayAdapter; Index++)
145 ShowWindow(pContext->hDisplayWnd[Index], SW_HIDE);
146
147 for(Index = 0; Index < pContext->NumSoundAdapter; Index++)
148 ShowWindow(pContext->hSoundWnd[Index], SW_HIDE);
149
150
151 if (CurSel == 0 || CurSel > pContext->NumDisplayAdapter + pContext->NumSoundAdapter)
152 {
153 if (CurSel)
154 CurSel -= pContext->NumDisplayAdapter + pContext->NumSoundAdapter;
155 ShowWindow(pContext->hDialogs[CurSel], SW_SHOW);
156 return;
157 }
158
159 if (CurSel -1 < pContext->NumDisplayAdapter)
160 {
161 ShowWindow(pContext->hDisplayWnd[CurSel-1], SW_SHOW);
162 return;
163 }
164
165 CurSel -= pContext->NumDisplayAdapter + 1;
166 ShowWindow(pContext->hSoundWnd[CurSel], SW_SHOW);
167}
168
169VOID
171{
172 /* get tabctrl */
174 pContext->hTabCtrl = hTabCtrlWnd;
175
176 /* create the dialogs */
182
183 /* insert tab ctrl items */
191 TabCtrl_OnSelChange(pContext);
192}
193
194VOID
196{
197 PDXDIAG_CONTEXT pContext;
198 HICON hIcon;
199
201 if (!pContext)
202 return;
203
204 /* store window handle */
205 pContext->hMainDialog = hwndDlg;
206
207 /* store the context */
208 SetWindowLongPtr(hwndDlg, DWLP_USER, (LONG_PTR)pContext);
209
210 /* initialize the tab ctrl */
211 InitializeTabCtrl(hwndDlg, pContext);
212
213 /* load application icon */
215 if (!hIcon)
216 return;
217 /* display icon */
218 SendMessage(hwndDlg, WM_SETICON, ICON_SMALL, (LPARAM)hIcon);
219}
220
221
224{
225 LPNMHDR pnmh;
226 PDXDIAG_CONTEXT pContext;
227
228 pContext = (PDXDIAG_CONTEXT)GetWindowLongPtr(hwndDlg, DWLP_USER);
229
230 switch (message)
231 {
232 case WM_INITDIALOG:
233 InitializeDxDiagDialog(hwndDlg);
234 return TRUE;
235 case WM_COMMAND:
237 {
238 //TODO
239 /* handle save information */
240 return TRUE;
241 }
242
244 {
245 INT CurSel;
246
247 /* retrieve current page */
249 CurSel++;
250
251 /* enable/disable next button */
253 (CurSel != TabCtrl_GetItemCount(hTabCtrlWnd) - 1));
254
255 /* switch to next tab */
257
258 /* show next page */
259 TabCtrl_OnSelChange(pContext);
260 return TRUE;
261 }
262
264 {
265 //TODO
266 /* handle help button */
267 return TRUE;
268 }
269
271 EndDialog(hwndDlg, LOWORD(wParam));
272 return TRUE;
273 }
274 break;
275
276 case WM_NOTIFY:
277 pnmh = (LPNMHDR)lParam;
278 if ((pnmh->hwndFrom == hTabCtrlWnd) && (pnmh->idFrom == IDC_TAB_CONTROL) && (pnmh->code == TCN_SELCHANGE))
279 {
281
282 /* enable/disable next button */
284 (CurSel != TabCtrl_GetItemCount(hTabCtrlWnd) - 1));
285
286 TabCtrl_OnSelChange(pContext);
287 }
288 break;
289 case WM_DESTROY:
290 DestroyTabCtrlDialogs(pContext);
291 return DefWindowProc(hwndDlg, message, wParam, lParam);
292 }
293 return 0;
294}
295
297 HINSTANCE hPrevInstance,
298 LPWSTR lpCmdLine,
299 int nCmdShow)
300{
301
303
304 UNREFERENCED_PARAMETER(hPrevInstance);
305 UNREFERENCED_PARAMETER(lpCmdLine);
306 UNREFERENCED_PARAMETER(nCmdShow);
307
308 InitControls.dwSize = sizeof(INITCOMMONCONTROLSEX);
311
313
315
316 return 0;
317}
void InitializeDisplayAdapters(PDXDIAG_CONTEXT pContext)
Definition: display.c:308
INT_PTR CALLBACK HelpPageWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
Definition: help.c:13
INT_PTR CALLBACK InputPageWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
Definition: input.c:207
INT_PTR CALLBACK NetworkPageWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
Definition: network.c:342
INT_PTR CALLBACK SystemPageWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
Definition: system.c:393
struct DXDIAG_CONTEXT * PDXDIAG_CONTEXT
void InitializeDirectSoundPage(PDXDIAG_CONTEXT pContext)
Definition: sound.c:265
#define IDD_MUSIC_DIALOG
Definition: resource.h:10
#define IDC_BUTTON_EXIT
Definition: resource.h:20
#define IDD_MAIN_DIALOG
Definition: resource.h:6
#define IDS_MUSIC_DIALOG
Definition: resource.h:107
#define IDS_NETWORK_DIALOG
Definition: resource.h:109
#define IDD_HELP_DIALOG
Definition: resource.h:13
#define IDC_BUTTON_NEXT
Definition: resource.h:18
#define IDD_SYSTEM_DIALOG
Definition: resource.h:7
#define IDD_NETWORK_DIALOG
Definition: resource.h:12
#define IDC_BUTTON_SAVE_INFO
Definition: resource.h:19
#define IDD_INPUT_DIALOG
Definition: resource.h:11
#define IDI_APPICON
Definition: resource.h:166
#define IDS_HELP_DIALOG
Definition: resource.h:110
#define IDS_SYSTEM_DIALOG
Definition: resource.h:104
#define IDC_BUTTON_HELP
Definition: resource.h:17
#define IDS_INPUT_DIALOG
Definition: resource.h:108
#define IDC_TAB_CONTROL
Definition: resource.h:16
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 NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define APIENTRY
Definition: api.h:79
#define GetProcessHeap()
Definition: compat.h:736
HANDLE HWND
Definition: compat.h:19
#define GetProcAddress(x, y)
Definition: compat.h:753
#define HeapAlloc
Definition: compat.h:733
#define FreeLibrary(x)
Definition: compat.h:748
#define CALLBACK
Definition: compat.h:35
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
HINSTANCE WINAPI DECLSPEC_HOTPATCH LoadLibraryA(LPCSTR lpLibFileName)
Definition: loader.c:111
HRESULT(WINAPI * ETDTProc)(HWND, DWORD)
Definition: dxdiag.c:33
#define ETDT_ENABLETAB
Definition: dxdiag.c:30
VOID TabCtrl_OnSelChange(PDXDIAG_CONTEXT pContext)
Definition: dxdiag.c:130
VOID InitializeDxDiagDialog(HWND hwndDlg)
Definition: dxdiag.c:195
HINSTANCE hInst
Definition: dxdiag.c:13
BOOL EnableDialogTheme(HWND hwnd)
Definition: dxdiag.c:38
VOID InsertTabCtrlItem(HWND hDlgCtrl, INT Position, LPWSTR uId)
Definition: dxdiag.c:102
VOID InitializeTabCtrl(HWND hwndDlg, PDXDIAG_CONTEXT pContext)
Definition: dxdiag.c:170
VOID DestroyTabCtrlDialogs(PDXDIAG_CONTEXT pContext)
Definition: dxdiag.c:73
HWND hTabCtrlWnd
Definition: dxdiag.c:14
int APIENTRY wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int nCmdShow)
Definition: dxdiag.c:296
INT_PTR CALLBACK DxDiagWndProc(HWND hwndDlg, UINT message, WPARAM wParam, LPARAM lParam)
Definition: dxdiag.c:223
unsigned int BOOL
Definition: ntddk_ex.h:94
static HICON
Definition: imagelist.c:80
static ATOM item
Definition: dde.c:856
static VOID InitControls(HWND hwnd)
Definition: mplay32.c:303
HICON hIcon
Definition: msconfig.c:44
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
INT_PTR CALLBACK MusicPageWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
Definition: music.c:13
unsigned int UINT
Definition: ndis.h:50
#define DWORD
Definition: nt_native.h:44
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
#define L(x)
Definition: ntvdm.h:50
#define LOWORD(l)
Definition: pedump.c:82
static const WCHAR szName[]
Definition: powrprof.c:45
#define TCM_INSERTITEM
Definition: commctrl.h:4054
#define TabCtrl_GetCurSel(hwnd)
Definition: commctrl.h:4068
struct tagINITCOMMONCONTROLSEX INITCOMMONCONTROLSEX
#define ICC_TREEVIEW_CLASSES
Definition: commctrl.h:59
#define TabCtrl_GetItemCount(hwnd)
Definition: commctrl.h:3974
#define ICC_STANDARD_CLASSES
Definition: commctrl.h:73
#define ICC_TAB_CLASSES
Definition: commctrl.h:61
#define TCN_SELCHANGE
Definition: commctrl.h:4137
#define TCM_SETCURSEL
Definition: commctrl.h:4070
#define TCIF_TEXT
Definition: commctrl.h:3976
#define ICC_LISTVIEW_CLASSES
Definition: commctrl.h:58
#define WM_NOTIFY
Definition: richedit.h:61
#define DefWindowProc
Definition: ros2win.h:31
#define memset(x, y, z)
Definition: compat.h:39
HWND hMainDialog
Definition: precomp.h:31
HWND * hSoundWnd
Definition: precomp.h:36
ULONG NumSoundAdapter
Definition: precomp.h:35
HWND * hDisplayWnd
Definition: precomp.h:34
ULONG NumDisplayAdapter
Definition: precomp.h:33
HWND hDialogs[5]
Definition: precomp.h:37
HWND hTabCtrl
Definition: precomp.h:32
Definition: tftpd.h:60
UINT_PTR idFrom
Definition: winuser.h:3161
UINT code
Definition: winuser.h:3162
HWND hwndFrom
Definition: winuser.h:3160
static COORD Position
Definition: mouse.c:34
#define ICON_SMALL
Definition: tnclass.cpp:48
#define GetWindowLongPtr
Definition: treelist.c:73
#define SetWindowLongPtr
Definition: treelist.c:70
int32_t INT_PTR
Definition: typedefs.h:64
int32_t INT
Definition: typedefs.h:58
#define HIWORD(l)
Definition: typedefs.h:247
static ETDTProc fnEnableThemeDialogTexture
Definition: uxthemesupp.c:15
_In_ WDFCOLLECTION _In_ ULONG Index
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023
LONG_PTR LPARAM
Definition: windef.h:208
UINT_PTR WPARAM
Definition: windef.h:207
#define HRESULT
Definition: msvc.h:7
#define WINAPI
Definition: msvc.h:6
HWND WINAPI CreateDialogParamW(_In_opt_ HINSTANCE, _In_ LPCWSTR, _In_opt_ HWND, _In_opt_ DLGPROC, _In_ LPARAM)
#define SW_HIDE
Definition: winuser.h:771
#define DWLP_USER
Definition: winuser.h:875
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
#define IDCANCEL
Definition: winuser.h:834
#define IMAGE_ICON
Definition: winuser.h:212
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
#define WM_COMMAND
Definition: winuser.h:1743
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:2247
#define WM_INITDIALOG
Definition: winuser.h:1742
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
struct tagNMHDR * LPNMHDR
#define SendMessage
Definition: winuser.h:5855
BOOL WINAPI EnableWindow(_In_ HWND, _In_ BOOL)
#define SW_SHOW
Definition: winuser.h:778
#define WM_DESTROY
Definition: winuser.h:1612
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
BOOL WINAPI DestroyWindow(_In_ HWND)
#define MAKEINTRESOURCE
Definition: winuser.h:591
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define DialogBox
Definition: winuser.h:5773
BOOL WINAPI EndDialog(_In_ HWND, _In_ INT_PTR)
__wchar_t WCHAR
Definition: xmlstorage.h:180
WCHAR * LPWSTR
Definition: xmlstorage.h:184