Skip to content

Commit 6f47c88

Browse files
committed
[DXDIAG] Add a structure to contain all data related to one display
Also change user pointer of display page to be the PDXDIAG_DISPLAY structure.
1 parent 4f7736a commit 6f47c88

File tree

3 files changed

+30
-17
lines changed

3 files changed

+30
-17
lines changed

base/applications/dxdiag/display.c

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,8 @@ InitializeDialog(HWND hwndDlg, PDISPLAY_DEVICEW pDispDevice)
308308
void InitializeDisplayAdapters(PDXDIAG_CONTEXT pContext)
309309
{
310310
DISPLAY_DEVICEW DispDevice;
311-
HWND * hDlgs;
311+
PDXDIAG_DISPLAY *pDisplayAdapters;
312+
PDXDIAG_DISPLAY pDisplayAdapter;
312313
HWND hwndDlg;
313314
WCHAR szDisplay[20];
314315
WCHAR szText[30];
@@ -328,15 +329,19 @@ void InitializeDisplayAdapters(PDXDIAG_CONTEXT pContext)
328329
continue;
329330
}
330331
if (pContext->NumDisplayAdapter)
331-
hDlgs = HeapReAlloc(GetProcessHeap(), 0, pContext->hDisplayWnd, (pContext->NumDisplayAdapter + 1) * sizeof(HWND));
332+
pDisplayAdapters = HeapReAlloc(GetProcessHeap(), 0, pContext->DisplayAdapters, (pContext->NumDisplayAdapter + 1) * sizeof(PDXDIAG_DISPLAY));
332333
else
333-
hDlgs = HeapAlloc(GetProcessHeap(), 0, (pContext->NumDisplayAdapter + 1) * sizeof(HWND));
334+
pDisplayAdapters = HeapAlloc(GetProcessHeap(), 0, sizeof(PDXDIAG_DISPLAY));
334335

335-
if (!hDlgs)
336+
if (!pDisplayAdapters)
336337
break;
337338

338-
pContext->hDisplayWnd = hDlgs;
339-
hwndDlg = CreateDialogParamW(hInst, MAKEINTRESOURCEW(IDD_DISPLAY_DIALOG), pContext->hMainDialog, DisplayPageWndProc, (LPARAM)pContext); EnableDialogTheme(hwndDlg);
339+
pDisplayAdapter = HeapAlloc(GetProcessHeap(), 0, sizeof(DXDIAG_DISPLAY));
340+
if (!pDisplayAdapter)
341+
break;
342+
343+
pContext->DisplayAdapters = pDisplayAdapters;
344+
hwndDlg = CreateDialogParamW(hInst, MAKEINTRESOURCEW(IDD_DISPLAY_DIALOG), pContext->hMainDialog, DisplayPageWndProc, (LPARAM)pDisplayAdapter); EnableDialogTheme(hwndDlg);
340345
if (!hwndDlg)
341346
break;
342347

@@ -350,7 +355,8 @@ void InitializeDisplayAdapters(PDXDIAG_CONTEXT pContext)
350355
wsprintfW (szText, L"%s %u", szDisplay, pContext->NumDisplayAdapter + 1);
351356
InsertTabCtrlItem(GetDlgItem(pContext->hMainDialog, IDC_TAB_CONTROL), pContext->NumDisplayAdapter + 1, szText);
352357

353-
hDlgs[pContext->NumDisplayAdapter] = hwndDlg;
358+
pDisplayAdapter->hDisplayWnd = hwndDlg;
359+
pDisplayAdapters[pContext->NumDisplayAdapter] = pDisplayAdapter;
354360
pContext->NumDisplayAdapter++;
355361
}
356362

@@ -362,13 +368,14 @@ INT_PTR CALLBACK
362368
DisplayPageWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
363369
{
364370
RECT rect;
365-
PDXDIAG_CONTEXT pContext = (PDXDIAG_CONTEXT)GetWindowLongPtr(hDlg, DWLP_USER);
371+
HWND hMainDialog;
372+
PDXDIAG_DISPLAY pDisplay = (PDXDIAG_DISPLAY)GetWindowLongPtr(hDlg, DWLP_USER);
366373
switch (message)
367374
{
368375
case WM_INITDIALOG:
369376
{
370-
pContext = (PDXDIAG_CONTEXT) lParam;
371-
SetWindowLongPtr(hDlg, DWLP_USER, (LONG_PTR)pContext);
377+
pDisplay = (PDXDIAG_DISPLAY) lParam;
378+
SetWindowLongPtr(hDlg, DWLP_USER, (LONG_PTR)pDisplay);
372379
SetWindowPos(hDlg, NULL, 10, 32, 0, 0, SWP_NOACTIVATE | SWP_NOOWNERZORDER | SWP_NOSIZE | SWP_NOZORDER);
373380
return TRUE;
374381
}
@@ -378,13 +385,14 @@ DisplayPageWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
378385
{
379386
case IDC_BUTTON_TESTDD:
380387
case IDC_BUTTON_TEST3D:
381-
GetWindowRect(pContext->hMainDialog, &rect);
388+
hMainDialog = GetWindow(hDlg, GW_OWNER);
389+
GetWindowRect(hMainDialog, &rect);
382390
/* FIXME log result errors */
383391
if (IDC_BUTTON_TESTDD == LOWORD(wParam))
384392
DDTests();
385393
else if (IDC_BUTTON_TEST3D == LOWORD(wParam))
386394
D3DTests();
387-
SetWindowPos(pContext->hMainDialog, NULL, rect.left, rect.top, rect.right, rect.bottom, SWP_NOACTIVATE | SWP_NOOWNERZORDER | SWP_NOSIZE | SWP_NOZORDER);
395+
SetWindowPos(hMainDialog, NULL, rect.left, rect.top, rect.right, rect.bottom, SWP_NOACTIVATE | SWP_NOOWNERZORDER | SWP_NOSIZE | SWP_NOZORDER);
388396
break;
389397
}
390398
break;

base/applications/dxdiag/dxdiag.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,8 @@ DestroyTabCtrlDialogs(PDXDIAG_CONTEXT pContext)
8484
/* destroy display dialogs */
8585
for(Index = 0; Index < pContext->NumDisplayAdapter; Index++)
8686
{
87-
if (pContext->hDisplayWnd[Index])
88-
DestroyWindow(pContext->hDisplayWnd[Index]);
87+
if (pContext->DisplayAdapters[Index]->hDisplayWnd)
88+
DestroyWindow(pContext->DisplayAdapters[Index]->hDisplayWnd);
8989
}
9090

9191
/* destroy audio dialogs */
@@ -142,7 +142,7 @@ TabCtrl_OnSelChange(PDXDIAG_CONTEXT pContext)
142142
ShowWindow(pContext->hDialogs[Index], SW_HIDE);
143143

144144
for(Index = 0; Index < pContext->NumDisplayAdapter; Index++)
145-
ShowWindow(pContext->hDisplayWnd[Index], SW_HIDE);
145+
ShowWindow(pContext->DisplayAdapters[Index]->hDisplayWnd, SW_HIDE);
146146

147147
for(Index = 0; Index < pContext->NumSoundAdapter; Index++)
148148
ShowWindow(pContext->hSoundWnd[Index], SW_HIDE);
@@ -158,7 +158,7 @@ TabCtrl_OnSelChange(PDXDIAG_CONTEXT pContext)
158158

159159
if (CurSel -1 < pContext->NumDisplayAdapter)
160160
{
161-
ShowWindow(pContext->hDisplayWnd[CurSel-1], SW_SHOW);
161+
ShowWindow(pContext->DisplayAdapters[CurSel-1]->hDisplayWnd, SW_SHOW);
162162
return;
163163
}
164164

base/applications/dxdiag/precomp.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,17 @@
2626

2727
#include "resource.h"
2828

29+
typedef struct
30+
{
31+
HWND hDisplayWnd;
32+
} DXDIAG_DISPLAY, *PDXDIAG_DISPLAY;
33+
2934
typedef struct
3035
{
3136
HWND hMainDialog;
3237
HWND hTabCtrl;
3338
ULONG NumDisplayAdapter;
34-
HWND * hDisplayWnd;
39+
PDXDIAG_DISPLAY * DisplayAdapters;
3540
ULONG NumSoundAdapter;
3641
HWND * hSoundWnd;
3742
HWND hDialogs[5];

0 commit comments

Comments
 (0)