Author: janderwald
Date: Tue Apr 29 07:19:55 2008
New Revision: 33188
URL:
http://svn.reactos.org/svn/reactos?rev=33188&view=rev
Log:
- fix flickering of DirectDraw tests by Pigglesworth (Kamil Hornicek)
- enumerate all available display / sound adapters dynamically at start (does not work
yet)
- rewrite TabCtrl_OnSelChange to reflect changes
Modified:
trunk/reactos/base/applications/dxdiag/ddtest.c
trunk/reactos/base/applications/dxdiag/display.c
trunk/reactos/base/applications/dxdiag/dxdiag.c
trunk/reactos/base/applications/dxdiag/precomp.h
trunk/reactos/base/applications/dxdiag/sound.c
Modified: trunk/reactos/base/applications/dxdiag/ddtest.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/dxdiag/d…
==============================================================================
--- trunk/reactos/base/applications/dxdiag/ddtest.c [iso-8859-1] (original)
+++ trunk/reactos/base/applications/dxdiag/ddtest.c [iso-8859-1] Tue Apr 29 07:19:55 2008
@@ -7,21 +7,20 @@
*
*/
-
#include "precomp.h"
BOOL DDPrimarySurfaceTest(HWND hWnd);
BOOL DDOffscreenBufferTest(HWND hWnd, BOOL Fullscreen);
VOID DDRedrawFrame(LPDIRECTDRAWSURFACE lpDDSurface);
VOID DDUpdateFrame(LPDIRECTDRAWSURFACE lpDDPrimarySurface ,LPDIRECTDRAWSURFACE
lpDDBackBuffer, BOOL Fullscreen, INT *posX, INT *posY, INT *gainX, INT *gainY, RECT
*rectDD);
-
-#define TEST_DURATION 5000
-#define WIDTH 800
-#define HEIGHT 600
+LRESULT CALLBACK WindowProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
+
+#define TEST_DURATION 10000
+#define WIDTH 640
+#define HEIGHT 480
#define DD_TEST_STEP 5
#define DD_SQUARE_SIZE 100
#define DD_SQUARE_STEP 2
-
BOOL StartDDTest(HWND hWnd, HINSTANCE hInstance, INT resTestDescription, INT resResult,
INT TestNr)
@@ -70,19 +69,50 @@
return FALSE;
}
-VOID DDTests(HWND hWnd, HINSTANCE hInstance)
-{
+VOID DDTests()
+{
+ WNDCLASSEX winClass;
+ HWND hWnd;
+ HINSTANCE hInstance = NULL;
WCHAR szDescription[256];
WCHAR szCaption[256];
+
+ winClass.cbSize = sizeof(WNDCLASSEX);
+ winClass.style = CS_DBLCLKS | CS_OWNDC | CS_HREDRAW | CS_VREDRAW;
+ winClass.lpfnWndProc = WindowProc;
+ winClass.cbClsExtra = 0;
+ winClass.cbWndExtra = 0;
+ winClass.hInstance = hInstance;
+ winClass.hIcon = 0;
+ winClass.hCursor = 0;
+ winClass.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
+ winClass.lpszMenuName = NULL;
+ winClass.lpszClassName = L"ddtest";
+ winClass.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
+
+ if (!RegisterClassEx(&winClass))
+ return;
+
+ hWnd = CreateWindowEx(0, winClass.lpszClassName, NULL,WS_POPUP,
+ (GetSystemMetrics(SM_CXSCREEN) - WIDTH)/2,
+ (GetSystemMetrics(SM_CYSCREEN) - HEIGHT)/2,
+ WIDTH, HEIGHT, NULL, NULL, hInstance, NULL);
+
+ if (!hWnd){
+ return;
+ }
LoadStringW(hInstance, IDS_DDTEST_DESCRIPTION, szDescription, sizeof(szDescription) /
sizeof(WCHAR));
LoadStringW(hInstance, IDS_DDTEST_DESCRIPTION, szCaption, sizeof(szCaption) /
sizeof(WCHAR));
if(MessageBox(NULL, szDescription, szCaption, MB_YESNO | MB_ICONQUESTION) == IDNO)
- PostQuitMessage(0);
+ return;
StartDDTest(hWnd, hInstance, IDS_DDPRIMARY_DESCRIPTION, IDS_DDPRIMARY_RESULT, 1);
StartDDTest(hWnd, hInstance, IDS_DDOFFSCREEN_DESCRIPTION, IDS_DDOFFSCREEN_RESULT,
2);
StartDDTest(hWnd, hInstance, IDS_DDFULLSCREEN_DESCRIPTION, IDS_DDFULLSCREEN_RESULT,
3);
+
+ DestroyWindow(hWnd);
+ UnregisterClass(winClass.lpszClassName, hInstance);
}
BOOL DDPrimarySurfaceTest(HWND hWnd){
@@ -334,3 +364,8 @@
}
}
}
+
+LRESULT CALLBACK WindowProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+ return DefWindowProc(hWnd, msg, wParam, lParam);
+}
Modified: trunk/reactos/base/applications/dxdiag/display.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/dxdiag/d…
==============================================================================
--- trunk/reactos/base/applications/dxdiag/display.c [iso-8859-1] (original)
+++ trunk/reactos/base/applications/dxdiag/display.c [iso-8859-1] Tue Apr 29 07:19:55
2008
@@ -173,8 +173,15 @@
HWND hDlgCtrls[3];
DWORD dwMemory;
DEVMODE DevMode;
-
DISPLAY_DEVICEW DispDevice;
+
+ /// FIXME
+ /// use initialization context
+ ///
+ ZeroMemory(&DispDevice, sizeof(DISPLAY_DEVICEW));
+ DispDevice.cb = sizeof(DISPLAY_DEVICEW);
+ if (!EnumDisplayDevicesW(NULL, 0, &DispDevice, 0))
+ return FALSE;
/* query display device adapter */
ZeroMemory(&DispDevice, sizeof(DISPLAY_DEVICEW));
@@ -275,6 +282,56 @@
return TRUE;
}
+void InitializeDisplayAdapters(PDXDIAG_CONTEXT pContext)
+{
+ DISPLAY_DEVICEW DispDevice;
+ HWND * hDlgs;
+ HWND hwndDlg;
+ WCHAR szDisplay[20];
+ WCHAR szText[30];
+ DWORD dwOffset = 0;
+
+ while(TRUE)
+ {
+ ZeroMemory(&DispDevice, sizeof(DISPLAY_DEVICEW));
+ DispDevice.cb = sizeof(DISPLAY_DEVICEW);
+ if (!EnumDisplayDevicesW(NULL, pContext->NumDisplayAdapter + dwOffset,
&DispDevice, 0))
+ return;
+
+ /* skip devices not attached to the desktop and mirror drivers */
+ if (!(DispDevice.StateFlags & DISPLAY_DEVICE_ATTACHED_TO_DESKTOP) ||
(DispDevice.StateFlags & DISPLAY_DEVICE_MIRRORING_DRIVER))
+ {
+ dwOffset++;
+ continue;
+ }
+ if (pContext->NumDisplayAdapter)
+ hDlgs = HeapReAlloc(GetProcessHeap(), 0, pContext->hDisplayWnd,
(pContext->NumDisplayAdapter + 1) * sizeof(HWND));
+ else
+ hDlgs = HeapAlloc(GetProcessHeap(), 0, (pContext->NumDisplayAdapter + 1) *
sizeof(HWND));
+
+ if (!hDlgs)
+ break;
+
+ pContext->hDisplayWnd = hDlgs;
+ hwndDlg = CreateDialogParamW(hInst, MAKEINTRESOURCEW(IDD_DISPLAY_DIALOG),
pContext->hMainDialog, DisplayPageWndProc, (LPARAM)pContext);
+ if (!hwndDlg)
+ break;
+
+ szDisplay[0] = L'\0';
+ LoadStringW(hInst, IDS_DISPLAY_DIALOG, szDisplay,
sizeof(szDisplay)/sizeof(WCHAR));
+ szDisplay[(sizeof(szDisplay)/sizeof(WCHAR))-1] = L'\0';
+
+ swprintf (szText, L"%s %u", szDisplay, pContext->NumDisplayAdapter +
1);
+ InsertTabCtrlItem(GetDlgItem(pContext->hMainDialog, IDC_TAB_CONTROL),
pContext->NumDisplayAdapter + 1, szText);
+
+ hDlgs[pContext->NumDisplayAdapter] = hwndDlg;
+ pContext->NumDisplayAdapter++;
+ }
+
+
+}
+
+
INT_PTR CALLBACK
DisplayPageWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
@@ -295,11 +352,7 @@
{
case IDC_BUTTON_TESTDD:
/* FIXME log result errors */
- ShowWindow(pContext->hMainDialog, SW_HIDE);
- StartDDTest(pContext->hMainDialog, hInst,
IDS_DDPRIMARY_DESCRIPTION, IDS_DDPRIMARY_RESULT, 1);
- StartDDTest(pContext->hMainDialog, hInst,
IDS_DDOFFSCREEN_DESCRIPTION, IDS_DDOFFSCREEN_RESULT, 2);
- StartDDTest(pContext->hMainDialog, hInst,
IDS_DDFULLSCREEN_DESCRIPTION, IDS_DDFULLSCREEN_RESULT, 3);
- ShowWindow(pContext->hMainDialog, SW_SHOW);
+ DDTests();
/* FIXME resize window */
break;
}
Modified: trunk/reactos/base/applications/dxdiag/dxdiag.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/dxdiag/d…
==============================================================================
--- trunk/reactos/base/applications/dxdiag/dxdiag.c [iso-8859-1] (original)
+++ trunk/reactos/base/applications/dxdiag/dxdiag.c [iso-8859-1] Tue Apr 29 07:19:55 2008
@@ -28,21 +28,29 @@
//---------------------------------------------------------------
VOID
-InsertTabCtrlItem(HWND hDlgCtrl, INT Position, UINT uId)
+InsertTabCtrlItem(HWND hDlgCtrl, INT Position, LPWSTR uId)
{
WCHAR szName[100];
TCITEMW item;
-
- /* load item name */
- szName[0] = L'\0';
- if (!LoadStringW(hInst, uId, szName, 100))
- return;
- szName[99] = L'\0';
/* setup item info */
memset(&item, 0, sizeof(TCITEM));
item.mask = TCIF_TEXT;
- item.pszText = szName;
+
+ /* load item name */
+ if (!HIWORD(uId))
+ {
+ szName[0] = L'\0';
+ if (!LoadStringW(hInst, LOWORD(uId), szName, 100))
+ return;
+ szName[99] = L'\0';
+ item.pszText = szName;
+ }
+ else
+ {
+ item.pszText = uId;
+ }
+
SendMessageW(hDlgCtrl, TCM_INSERTITEM, Position, (LPARAM)&item);
}
@@ -55,42 +63,55 @@
/* retrieve new page */
CurSel = TabCtrl_GetCurSel(hTabCtrlWnd);
- if (CurSel < 0 || CurSel > 7)
- return;
-
- /* show active page */
- for(Index = 0; Index < 7; Index++)
- {
- if (Index == CurSel)
- ShowWindow(pContext->hDialogs[Index], SW_SHOW);
- else
- ShowWindow(pContext->hDialogs[Index], SW_HIDE);
- }
-}
-
+ if (CurSel < 0 || CurSel > pContext->NumDisplayAdapter +
pContext->NumSoundAdapter + 5)
+ return;
+
+ /* hide all windows */
+ for(Index = 0; Index < 5; Index++)
+ ShowWindow(pContext->hDialogs[Index], SW_HIDE);
+
+ for(Index = 0; Index < pContext->NumDisplayAdapter; Index++)
+ ShowWindow(pContext->hDisplayWnd[Index], SW_HIDE);
+
+ for(Index = 0; Index < pContext->NumSoundAdapter; Index++)
+ ShowWindow(pContext->hSoundWnd[Index], SW_HIDE);
+
+
+ if (CurSel == 0 || CurSel > pContext->NumDisplayAdapter +
pContext->NumSoundAdapter)
+ {
+ ShowWindow(pContext->hDialogs[min(0,
CurSel-pContext->NumDisplayAdapter-pContext->NumSoundAdapter)], SW_SHOW);
+ return;
+ }
+
+ if (CurSel -1 < pContext->NumDisplayAdapter)
+ {
+ ShowWindow(pContext->hDisplayWnd[CurSel-1], SW_SHOW);
+ return;
+ }
+
+ CurSel -= pContext->NumDisplayAdapter + 1;
+ ShowWindow(pContext->hSoundWnd[CurSel], SW_SHOW);
+}
VOID
InitializeTabCtrl(HWND hwndDlg, PDXDIAG_CONTEXT pContext)
{
/* create the dialogs */
pContext->hDialogs[0] = CreateDialogParamW(hInst,
MAKEINTRESOURCEW(IDD_SYSTEM_DIALOG), hwndDlg, SystemPageWndProc, (LPARAM)pContext);
- pContext->hDialogs[1] = CreateDialogParamW(hInst,
MAKEINTRESOURCEW(IDD_DISPLAY_DIALOG), hwndDlg, DisplayPageWndProc, (LPARAM)pContext);
- pContext->hDialogs[2] = CreateDialogParamW(hInst,
MAKEINTRESOURCEW(IDD_SOUND_DIALOG), hwndDlg, SoundPageWndProc, (LPARAM)pContext);
- pContext->hDialogs[3] = CreateDialogParamW(hInst,
MAKEINTRESOURCEW(IDD_MUSIC_DIALOG), hwndDlg, MusicPageWndProc, (LPARAM)pContext);
- pContext->hDialogs[4] = CreateDialogParamW(hInst,
MAKEINTRESOURCEW(IDD_INPUT_DIALOG), hwndDlg, InputPageWndProc, (LPARAM)pContext);
- pContext->hDialogs[5] = CreateDialogParamW(hInst,
MAKEINTRESOURCEW(IDD_NETWORK_DIALOG), hwndDlg, NetworkPageWndProc, (LPARAM)pContext);
- pContext->hDialogs[6] = CreateDialogParamW(hInst,
MAKEINTRESOURCEW(IDD_HELP_DIALOG), hwndDlg, HelpPageWndProc, (LPARAM)pContext);
+ pContext->hDialogs[1] = CreateDialogParamW(hInst,
MAKEINTRESOURCEW(IDD_MUSIC_DIALOG), hwndDlg, MusicPageWndProc, (LPARAM)pContext);
+ pContext->hDialogs[2] = CreateDialogParamW(hInst,
MAKEINTRESOURCEW(IDD_INPUT_DIALOG), hwndDlg, InputPageWndProc, (LPARAM)pContext);
+ pContext->hDialogs[3] = CreateDialogParamW(hInst,
MAKEINTRESOURCEW(IDD_NETWORK_DIALOG), hwndDlg, NetworkPageWndProc, (LPARAM)pContext);
+ pContext->hDialogs[4] = CreateDialogParamW(hInst,
MAKEINTRESOURCEW(IDD_HELP_DIALOG), hwndDlg, HelpPageWndProc, (LPARAM)pContext);
/* insert tab ctrl items */
hTabCtrlWnd = GetDlgItem(hwndDlg, IDC_TAB_CONTROL);
- InsertTabCtrlItem(hTabCtrlWnd, 0, IDS_SYSTEM_DIALOG);
- InsertTabCtrlItem(hTabCtrlWnd, 1, IDS_DISPLAY_DIALOG);
- InsertTabCtrlItem(hTabCtrlWnd, 2, IDS_SOUND_DIALOG);
- InsertTabCtrlItem(hTabCtrlWnd, 3, IDS_MUSIC_DIALOG);
- InsertTabCtrlItem(hTabCtrlWnd, 4, IDS_INPUT_DIALOG);
- InsertTabCtrlItem(hTabCtrlWnd, 5, IDS_NETWORK_DIALOG);
- InsertTabCtrlItem(hTabCtrlWnd, 6, IDS_HELP_DIALOG);
-
+ InsertTabCtrlItem(hTabCtrlWnd, 0, MAKEINTRESOURCEW(IDS_SYSTEM_DIALOG));
+ InitializeDisplayAdapters(pContext);
+ InitializeDirectSoundPage(pContext);
+ InsertTabCtrlItem(hTabCtrlWnd, pContext->NumDisplayAdapter +
pContext->NumSoundAdapter + 1, MAKEINTRESOURCEW(IDS_MUSIC_DIALOG));
+ InsertTabCtrlItem(hTabCtrlWnd, pContext->NumDisplayAdapter +
pContext->NumSoundAdapter + 2, MAKEINTRESOURCEW(IDS_INPUT_DIALOG));
+ InsertTabCtrlItem(hTabCtrlWnd, pContext->NumDisplayAdapter +
pContext->NumSoundAdapter + 3, MAKEINTRESOURCEW(IDS_NETWORK_DIALOG));
+ InsertTabCtrlItem(hTabCtrlWnd, pContext->NumDisplayAdapter +
pContext->NumSoundAdapter + 4, MAKEINTRESOURCEW(IDS_HELP_DIALOG));
TabCtrl_OnSelChange(pContext);
}
Modified: trunk/reactos/base/applications/dxdiag/precomp.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/dxdiag/p…
==============================================================================
--- trunk/reactos/base/applications/dxdiag/precomp.h [iso-8859-1] (original)
+++ trunk/reactos/base/applications/dxdiag/precomp.h [iso-8859-1] Tue Apr 29 07:19:55
2008
@@ -20,7 +20,11 @@
typedef struct
{
HWND hMainDialog;
- HWND hDialogs[7];
+ ULONG NumDisplayAdapter;
+ HWND * hDisplayWnd;
+ ULONG NumSoundAdapter;
+ HWND * hSoundWnd;
+ HWND hDialogs[5];
}DXDIAG_CONTEXT, *PDXDIAG_CONTEXT;
@@ -39,9 +43,16 @@
INT_PTR CALLBACK HelpPageWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);
BOOL GetRegValue(HKEY hBaseKey, LPWSTR SubKey, LPWSTR ValueName, DWORD Type, LPWSTR
Result, DWORD Size);
+VOID InsertTabCtrlItem(HWND hDlgCtrl, INT Position, LPWSTR uId);
+
/* DirectDraw tests */
-BOOL StartDDTest(HWND hWnd, HINSTANCE hInstance, INT resTestDescription, INT resResult,
INT TestNr);
+VOID DDTests();
+/* DirectSound initialization */
+void InitializeDirectSoundPage(PDXDIAG_CONTEXT pContext);
+
+/* display adapter initialization */
+void InitializeDisplayAdapters(PDXDIAG_CONTEXT pContext);
BOOL GetFileVersion(LPCWSTR szAppName, WCHAR * szVer, DWORD szVerSize);
BOOL GetFileModifyTime(LPCWSTR pFullPath, WCHAR * szTime, int szTimeSize);
Modified: trunk/reactos/base/applications/dxdiag/sound.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/dxdiag/s…
==============================================================================
--- trunk/reactos/base/applications/dxdiag/sound.c [iso-8859-1] (original)
+++ trunk/reactos/base/applications/dxdiag/sound.c [iso-8859-1] Tue Apr 29 07:19:55 2008
@@ -9,6 +9,62 @@
#include "precomp.h"
+BOOL CALLBACK DSEnumCallback(LPGUID lpGuid, LPCWSTR lpcstrDescription, LPCWSTR
lpcstrModule, LPVOID lpContext)
+{
+ PDXDIAG_CONTEXT pContext = (PDXDIAG_CONTEXT)lpContext;
+ HWND * hDlgs;
+ HWND hwndDlg;
+ WCHAR szSound[20];
+ WCHAR szText[30];
+
+ if (!lpGuid)
+ return TRUE;
+
+ if (pContext->NumSoundAdapter)
+ hDlgs = HeapReAlloc(GetProcessHeap(), 0, pContext->hSoundWnd,
(pContext->NumSoundAdapter + 1) * sizeof(HWND));
+ else
+ hDlgs = HeapAlloc(GetProcessHeap(), 0, (pContext->NumSoundAdapter + 1) *
sizeof(HWND));
+
+ if (!hDlgs)
+ return FALSE;
+
+ pContext->hSoundWnd = hDlgs;
+ hwndDlg = CreateDialogParamW(hInst, MAKEINTRESOURCEW(IDD_SOUND_DIALOG),
pContext->hMainDialog, SoundPageWndProc, (LPARAM)pContext);
+ if (!hwndDlg)
+ return FALSE;
+
+ szSound[0] = L'\0';
+ LoadStringW(hInst, IDS_SOUND_DIALOG, szSound, sizeof(szSound)/sizeof(WCHAR));
+ szSound[(sizeof(szSound)/sizeof(WCHAR))-1] = L'\0';
+
+ swprintf (szText, L"%s %u", szSound, pContext->NumSoundAdapter + 1);
+
+
+ InsertTabCtrlItem(GetDlgItem(pContext->hMainDialog, IDC_TAB_CONTROL),
pContext->NumDisplayAdapter + pContext->NumSoundAdapter + 1, szText);
+
+ hDlgs[pContext->NumSoundAdapter] = hwndDlg;
+ pContext->NumSoundAdapter++;
+
+ return TRUE;
+}
+
+
+void InitializeDirectSoundPage(PDXDIAG_CONTEXT pContext)
+{
+ HRESULT hResult;
+ //IDirectSound8 *pObj;
+
+ /* create DSound object */
+// hResult = DirectSoundCreate8(NULL, (LPDIRECTSOUND8*)&pObj, NULL);
+// if (hResult != DS_OK)
+// return;
+ hResult = DirectSoundEnumerateW(DSEnumCallback, pContext);
+
+ /* release the DSound object */
+// pObj->lpVtbl->Release(pObj);
+}
+
+
INT_PTR CALLBACK
SoundPageWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
@@ -18,6 +74,7 @@
case WM_INITDIALOG:
{
SetWindowPos(hDlg, NULL, 10, 32, 0, 0, SWP_NOACTIVATE | SWP_NOOWNERZORDER |
SWP_NOSIZE | SWP_NOZORDER);
+ //InitializeDirectSoundPage(hDlg);
return TRUE;
}
}