/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS Display Control Panel
- * FILE: lib/cpl/desk/settings.c
+ * FILE: dll/cpl/desk/settings.c
* PURPOSE: Settings property page
*
* PROGRAMMERS: Trevor McCort (lycan359@gmail.com)
*/
#include "desk.h"
-#include "monslctl.h"
-typedef struct _GLOBAL_DATA
+typedef struct _DATA
{
PDISPLAY_DEVICE_ENTRY DisplayDeviceList;
PDISPLAY_DEVICE_ENTRY CurrentDisplayDevice;
HBITMAP hSpectrumBitmaps[NUM_SPECTRUM_BITMAPS];
int cxSource[NUM_SPECTRUM_BITMAPS];
int cySource[NUM_SPECTRUM_BITMAPS];
-} GLOBAL_DATA, *PGLOBAL_DATA;
+} DATA, *PDATA;
static VOID
-UpdateDisplay(IN HWND hwndDlg, PGLOBAL_DATA pGlobalData, IN BOOL bUpdateThumb)
+UpdateDisplay(IN HWND hwndDlg, PDATA pData, IN BOOL bUpdateThumb)
{
TCHAR Buffer[64];
TCHAR Pixel[64];
DWORD index;
LoadString(hApplet, IDS_PIXEL, Pixel, sizeof(Pixel) / sizeof(TCHAR));
- _stprintf(Buffer, Pixel, pGlobalData->CurrentDisplayDevice->CurrentSettings->dmPelsWidth, pGlobalData->CurrentDisplayDevice->CurrentSettings->dmPelsHeight, Pixel);
+ _stprintf(Buffer, Pixel, pData->CurrentDisplayDevice->CurrentSettings->dmPelsWidth, pData->CurrentDisplayDevice->CurrentSettings->dmPelsHeight, Pixel);
SendDlgItemMessage(hwndDlg, IDC_SETTINGS_RESOLUTION_TEXT, WM_SETTEXT, 0, (LPARAM)Buffer);
- for (index = 0; index < pGlobalData->CurrentDisplayDevice->ResolutionsCount; index++)
+ for (index = 0; index < pData->CurrentDisplayDevice->ResolutionsCount; index++)
{
- if (pGlobalData->CurrentDisplayDevice->Resolutions[index].dmPelsWidth == pGlobalData->CurrentDisplayDevice->CurrentSettings->dmPelsWidth &&
- pGlobalData->CurrentDisplayDevice->Resolutions[index].dmPelsHeight == pGlobalData->CurrentDisplayDevice->CurrentSettings->dmPelsHeight)
+ if (pData->CurrentDisplayDevice->Resolutions[index].dmPelsWidth == pData->CurrentDisplayDevice->CurrentSettings->dmPelsWidth &&
+ pData->CurrentDisplayDevice->Resolutions[index].dmPelsHeight == pData->CurrentDisplayDevice->CurrentSettings->dmPelsHeight)
{
if (bUpdateThumb)
SendDlgItemMessage(hwndDlg, IDC_SETTINGS_RESOLUTION, TBM_SETPOS, TRUE, index);
break;
}
}
- if (LoadString(hApplet, (2900 + pGlobalData->CurrentDisplayDevice->CurrentSettings->dmBitsPerPel), Buffer, sizeof(Buffer) / sizeof(TCHAR)))
+ if (LoadString(hApplet, (2900 + pData->CurrentDisplayDevice->CurrentSettings->dmBitsPerPel), Buffer, sizeof(Buffer) / sizeof(TCHAR)))
SendDlgItemMessage(hwndDlg, IDC_SETTINGS_BPP, CB_SELECTSTRING, (WPARAM)-1, (LPARAM)Buffer);
}
Current->dmPelsWidth = devmode.dmPelsWidth;
Current->dmPelsHeight = devmode.dmPelsHeight;
Current->dmBitsPerPel = devmode.dmBitsPerPel;
+ Current->dmDisplayFrequency = devmode.dmDisplayFrequency;
while (Next != NULL && (
Next->dmPelsWidth < Current->dmPelsWidth ||
(Next->dmPelsWidth == Current->dmPelsWidth && Next->dmPelsHeight < Current->dmPelsHeight) ||
}
static BOOL
-AddDisplayDevice(IN PGLOBAL_DATA pGlobalData, IN const DISPLAY_DEVICE *DisplayDevice)
+AddDisplayDevice(IN PDATA pData, IN const DISPLAY_DEVICE *DisplayDevice)
{
PDISPLAY_DEVICE_ENTRY newEntry = NULL;
LPTSTR description = NULL;
DWORD ResolutionsCount = 1;
DWORD i;
- newEntry = HeapAlloc(GetProcessHeap(), 0, sizeof(DISPLAY_DEVICE_ENTRY));
- memset(newEntry, 0, sizeof(DISPLAY_DEVICE_ENTRY));
+ newEntry = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(DISPLAY_DEVICE_ENTRY));
if (!newEntry) goto ByeBye;
newEntry->Settings = GetPossibleSettings(DisplayDevice->DeviceName, &newEntry->SettingsCount, &newEntry->CurrentSettings);
newEntry->DeviceKey = key;
newEntry->DeviceID = devid;
newEntry->DeviceStateFlags = DisplayDevice->StateFlags;
- newEntry->Flink = pGlobalData->DisplayDeviceList;
- pGlobalData->DisplayDeviceList = newEntry;
+ newEntry->Flink = pData->DisplayDeviceList;
+ pData->DisplayDeviceList = newEntry;
return TRUE;
ByeBye:
}
static VOID
-OnDisplayDeviceChanged(IN HWND hwndDlg, IN PGLOBAL_DATA pGlobalData, IN PDISPLAY_DEVICE_ENTRY pDeviceEntry)
+OnDisplayDeviceChanged(IN HWND hwndDlg, IN PDATA pData, IN PDISPLAY_DEVICE_ENTRY pDeviceEntry)
{
PSETTINGS_ENTRY Current;
DWORD index;
- pGlobalData->CurrentDisplayDevice = pDeviceEntry; /* Update global variable */
+ pData->CurrentDisplayDevice = pDeviceEntry; /* Update variable */
/* Fill color depths combo box */
SendDlgItemMessage(hwndDlg, IDC_SETTINGS_BPP, CB_RESETCONTENT, 0, 0);
SendDlgItemMessage(hwndDlg, IDC_SETTINGS_RESOLUTION, TBM_CLEARTICS, TRUE, 0);
SendDlgItemMessage(hwndDlg, IDC_SETTINGS_RESOLUTION, TBM_SETRANGE, TRUE, MAKELONG(0, pDeviceEntry->ResolutionsCount - 1));
- UpdateDisplay(hwndDlg, pGlobalData, TRUE);
+ UpdateDisplay(hwndDlg, pData, TRUE);
}
static VOID
BITMAP bitmap;
DWORD Result = 0;
DWORD iDevNum = 0;
- INT i;
+ DWORD i;
DISPLAY_DEVICE displayDevice;
- PGLOBAL_DATA pGlobalData;
+ PDATA pData;
- pGlobalData = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(GLOBAL_DATA));
- if (pGlobalData == NULL)
+ pData = HeapAlloc(GetProcessHeap(), 0, sizeof(DATA));
+ if (pData == NULL)
return;
- SetWindowLongPtr(hwndDlg, DWLP_USER, (LONG_PTR)pGlobalData);
+ SetWindowLongPtr(hwndDlg, DWLP_USER, (LONG_PTR)pData);
/* Get video cards list */
+ pData->DisplayDeviceList = NULL;
displayDevice.cb = (DWORD)sizeof(DISPLAY_DEVICE);
while (EnumDisplayDevices(NULL, iDevNum, &displayDevice, 0x1))
{
if ((displayDevice.StateFlags & DISPLAY_DEVICE_ATTACHED_TO_DESKTOP) != 0)
{
- if (AddDisplayDevice(pGlobalData, &displayDevice))
+ if (AddDisplayDevice(pData, &displayDevice))
Result++;
}
iDevNum++;
}
+
if (Result == 0)
{
/* No adapter found */
EnableWindow(GetDlgItem(hwndDlg, IDC_SETTINGS_RESOLUTION), FALSE);
EnableWindow(GetDlgItem(hwndDlg, IDC_SETTINGS_RESOLUTION_TEXT), FALSE);
EnableWindow(GetDlgItem(hwndDlg, IDC_SETTINGS_ADVANCED), FALSE);
+ ShowWindow(GetDlgItem(hwndDlg, IDC_SETTINGS_SPECTRUM), SW_HIDE);
+
+ /* Do not initialize the color spectrum bitmaps */
+ memset(pData->hSpectrumBitmaps, 0, sizeof(pData->hSpectrumBitmaps));
+ return;
}
else if (Result == 1)
{
MONSL_MONINFO monitors;
/* Single video adapter */
- SendDlgItemMessage(hwndDlg, IDC_SETTINGS_DEVICE, WM_SETTEXT, 0, (LPARAM)pGlobalData->DisplayDeviceList->DeviceDescription);
- OnDisplayDeviceChanged(hwndDlg, pGlobalData, pGlobalData->DisplayDeviceList);
+ SendDlgItemMessage(hwndDlg, IDC_SETTINGS_DEVICE, WM_SETTEXT, 0, (LPARAM)pData->DisplayDeviceList->DeviceDescription);
+ OnDisplayDeviceChanged(hwndDlg, pData, pData->DisplayDeviceList);
monitors.Position.x = monitors.Position.y = 0;
- monitors.Size.cx = pGlobalData->CurrentDisplayDevice->CurrentSettings->dmPelsWidth;
- monitors.Size.cy = pGlobalData->CurrentDisplayDevice->CurrentSettings->dmPelsHeight;
+ monitors.Size.cx = pData->CurrentDisplayDevice->CurrentSettings->dmPelsWidth;
+ monitors.Size.cy = pData->CurrentDisplayDevice->CurrentSettings->dmPelsHeight;
monitors.Flags = 0;
SendDlgItemMessage(hwndDlg,
- IDC_SETTINGS_MONSEL,
- MSLM_SETMONITORSINFO,
- 1,
- (LPARAM)&monitors);
+ IDC_SETTINGS_MONSEL,
+ MSLM_SETMONITORSINFO,
+ 1,
+ (LPARAM)&monitors);
}
else /* FIXME: incomplete! */
{
PMONSL_MONINFO pMonitors;
- INT i;
+ DWORD i;
- SendDlgItemMessage(hwndDlg, IDC_SETTINGS_DEVICE, WM_SETTEXT, 0, (LPARAM)pGlobalData->DisplayDeviceList->DeviceDescription);
- OnDisplayDeviceChanged(hwndDlg, pGlobalData, pGlobalData->DisplayDeviceList);
+ SendDlgItemMessage(hwndDlg, IDC_SETTINGS_DEVICE, WM_SETTEXT, 0, (LPARAM)pData->DisplayDeviceList->DeviceDescription);
+ OnDisplayDeviceChanged(hwndDlg, pData, pData->DisplayDeviceList);
pMonitors = (PMONSL_MONINFO)HeapAlloc(GetProcessHeap(), 0, sizeof(MONSL_MONINFO) * Result);
if (pMonitors)
{
- INT hack = 1280;
+ DWORD hack = 1280;
for (i = 0; i < Result; i++)
{
pMonitors[i].Position.x = hack * i;
pMonitors[i].Position.y = 0;
- pMonitors[i].Size.cx = pGlobalData->DisplayDeviceList->CurrentSettings->dmPelsWidth;
- pMonitors[i].Size.cy = pGlobalData->DisplayDeviceList->CurrentSettings->dmPelsHeight;
+ pMonitors[i].Size.cx = pData->DisplayDeviceList->CurrentSettings->dmPelsWidth;
+ pMonitors[i].Size.cy = pData->DisplayDeviceList->CurrentSettings->dmPelsHeight;
pMonitors[i].Flags = 0;
}
SendDlgItemMessage(hwndDlg,
- IDC_SETTINGS_MONSEL,
- MSLM_SETMONITORSINFO,
- Result,
- (LPARAM)pMonitors);
+ IDC_SETTINGS_MONSEL,
+ MSLM_SETMONITORSINFO,
+ Result,
+ (LPARAM)pMonitors);
HeapFree(GetProcessHeap(), 0, pMonitors);
}
/* Initialize the color spectrum bitmaps */
for(i = 0; i < NUM_SPECTRUM_BITMAPS; i++)
{
- pGlobalData->hSpectrumBitmaps[i] = LoadImageW(hApplet, MAKEINTRESOURCEW(IDB_SPECTRUM_4 + i), IMAGE_BITMAP, 0, 0, LR_DEFAULTCOLOR);
+ pData->hSpectrumBitmaps[i] = LoadImageW(hApplet, MAKEINTRESOURCEW(IDB_SPECTRUM_4 + i), IMAGE_BITMAP, 0, 0, LR_DEFAULTCOLOR);
- if (pGlobalData->hSpectrumBitmaps[i] != NULL)
+ if (pData->hSpectrumBitmaps[i] != NULL)
{
- if (GetObjectW(pGlobalData->hSpectrumBitmaps[i], sizeof(BITMAP), &bitmap) != 0)
+ if (GetObjectW(pData->hSpectrumBitmaps[i], sizeof(BITMAP), &bitmap) != 0)
{
- pGlobalData->cxSource[i] = bitmap.bmWidth;
- pGlobalData->cySource[i] = bitmap.bmHeight;
+ pData->cxSource[i] = bitmap.bmWidth;
+ pData->cySource[i] = bitmap.bmHeight;
}
else
{
- pGlobalData->cxSource[i] = 0;
- pGlobalData->cySource[i] = 0;
+ pData->cxSource[i] = 0;
+ pData->cySource[i] = 0;
}
}
}
}
-/* Get the ID for GLOBAL_DATA::hSpectrumBitmaps */
+/* Get the ID for DATA::hSpectrumBitmaps */
static VOID
-ShowColorSpectrum(IN HDC hDC, IN LPRECT client, IN DWORD BitsPerPel, IN PGLOBAL_DATA pGlobalData)
+ShowColorSpectrum(IN HDC hDC, IN LPRECT client, IN DWORD BitsPerPel, IN PDATA pData)
{
HDC hdcMem;
INT iBitmap;
default: iBitmap = 2;
}
- SelectObject(hdcMem, pGlobalData->hSpectrumBitmaps[iBitmap]);
- StretchBlt(hDC,
- client->left, client->top, client->right - client->left, client->bottom - client->top,
- hdcMem, 0, 0,
- pGlobalData->cxSource[iBitmap],
- pGlobalData->cySource[iBitmap], SRCCOPY);
+ if (SelectObject(hdcMem, pData->hSpectrumBitmaps[iBitmap]))
+ {
+ StretchBlt(hDC,
+ client->left, client->top,
+ client->right - client->left,
+ client->bottom - client->top,
+ hdcMem, 0, 0,
+ pData->cxSource[iBitmap],
+ pData->cySource[iBitmap], SRCCOPY);
+ }
+
DeleteDC(hdcMem);
}
static VOID
-OnBPPChanged(IN HWND hwndDlg, IN PGLOBAL_DATA pGlobalData)
+OnBPPChanged(IN HWND hwndDlg, IN PDATA pData)
{
/* if new BPP is not compatible with resolution:
* 1) try to find the nearest smaller matching resolution
hSpectrumControl = GetDlgItem(hwndDlg, IDC_SETTINGS_SPECTRUM);
hSpectrumDC = GetDC(hSpectrumControl);
GetClientRect(hSpectrumControl, &client);
- ShowColorSpectrum(hSpectrumDC, &client, dmNewBitsPerPel, pGlobalData);
+ ShowColorSpectrum(hSpectrumDC, &client, dmNewBitsPerPel, pData);
/* find if new parameters are valid */
- Current = pGlobalData->CurrentDisplayDevice->CurrentSettings;
+ Current = pData->CurrentDisplayDevice->CurrentSettings;
if (dmNewBitsPerPel == Current->dmBitsPerPel)
{
/* no change */
while (Current != NULL)
{
if (Current->dmBitsPerPel == dmNewBitsPerPel
- && Current->dmPelsHeight == pGlobalData->CurrentDisplayDevice->CurrentSettings->dmPelsHeight
- && Current->dmPelsWidth == pGlobalData->CurrentDisplayDevice->CurrentSettings->dmPelsWidth)
+ && Current->dmPelsHeight == pData->CurrentDisplayDevice->CurrentSettings->dmPelsHeight
+ && Current->dmPelsWidth == pData->CurrentDisplayDevice->CurrentSettings->dmPelsWidth)
{
- pGlobalData->CurrentDisplayDevice->CurrentSettings = Current;
- UpdateDisplay(hwndDlg, pGlobalData, TRUE);
+ pData->CurrentDisplayDevice->CurrentSettings = Current;
+ UpdateDisplay(hwndDlg, pData, TRUE);
return;
}
Current = Current->Blink;
while (Current != NULL)
{
if (Current->dmBitsPerPel == dmNewBitsPerPel
- && Current->dmPelsHeight == pGlobalData->CurrentDisplayDevice->CurrentSettings->dmPelsHeight
- && Current->dmPelsWidth == pGlobalData->CurrentDisplayDevice->CurrentSettings->dmPelsWidth)
+ && Current->dmPelsHeight == pData->CurrentDisplayDevice->CurrentSettings->dmPelsHeight
+ && Current->dmPelsWidth == pData->CurrentDisplayDevice->CurrentSettings->dmPelsWidth)
{
- pGlobalData->CurrentDisplayDevice->CurrentSettings = Current;
- UpdateDisplay(hwndDlg, pGlobalData, TRUE);
+ pData->CurrentDisplayDevice->CurrentSettings = Current;
+ UpdateDisplay(hwndDlg, pData, TRUE);
return;
}
Current = Current->Flink;
}
/* search smaller resolution compatible with current color depth */
- Current = pGlobalData->CurrentDisplayDevice->CurrentSettings->Blink;
+ Current = pData->CurrentDisplayDevice->CurrentSettings->Blink;
while (Current != NULL)
{
if (Current->dmBitsPerPel == dmNewBitsPerPel)
{
- pGlobalData->CurrentDisplayDevice->CurrentSettings = Current;
- UpdateDisplay(hwndDlg, pGlobalData, TRUE);
+ pData->CurrentDisplayDevice->CurrentSettings = Current;
+ UpdateDisplay(hwndDlg, pData, TRUE);
return;
}
Current = Current->Blink;
}
/* search bigger resolution compatible with current color depth */
- Current = pGlobalData->CurrentDisplayDevice->CurrentSettings->Flink;
+ Current = pData->CurrentDisplayDevice->CurrentSettings->Flink;
while (Current != NULL)
{
if (Current->dmBitsPerPel == dmNewBitsPerPel)
{
- pGlobalData->CurrentDisplayDevice->CurrentSettings = Current;
- UpdateDisplay(hwndDlg, pGlobalData, TRUE);
+ pData->CurrentDisplayDevice->CurrentSettings = Current;
+ UpdateDisplay(hwndDlg, pData, TRUE);
return;
}
Current = Current->Flink;
}
static VOID
-OnResolutionChanged(IN HWND hwndDlg, IN PGLOBAL_DATA pGlobalData, IN DWORD NewPosition,
+OnResolutionChanged(IN HWND hwndDlg, IN PDATA pData, IN DWORD NewPosition,
IN BOOL bUpdateThumb)
{
/* if new resolution is not compatible with color depth:
* 2) otherwise, get the nearest smaller color depth
*/
PSETTINGS_ENTRY Current;
- DWORD dmNewPelsHeight = pGlobalData->CurrentDisplayDevice->Resolutions[NewPosition].dmPelsHeight;
- DWORD dmNewPelsWidth = pGlobalData->CurrentDisplayDevice->Resolutions[NewPosition].dmPelsWidth;
+ DWORD dmNewPelsHeight = pData->CurrentDisplayDevice->Resolutions[NewPosition].dmPelsHeight;
+ DWORD dmNewPelsWidth = pData->CurrentDisplayDevice->Resolutions[NewPosition].dmPelsWidth;
/* find if new parameters are valid */
- Current = pGlobalData->CurrentDisplayDevice->CurrentSettings;
+ Current = pData->CurrentDisplayDevice->CurrentSettings;
if (dmNewPelsHeight == Current->dmPelsHeight && dmNewPelsWidth == Current->dmPelsWidth)
{
/* no change */
{
if (Current->dmPelsHeight == dmNewPelsHeight
&& Current->dmPelsWidth == dmNewPelsWidth
- && Current->dmBitsPerPel == pGlobalData->CurrentDisplayDevice->CurrentSettings->dmBitsPerPel)
+ && Current->dmBitsPerPel == pData->CurrentDisplayDevice->CurrentSettings->dmBitsPerPel)
{
- pGlobalData->CurrentDisplayDevice->CurrentSettings = Current;
- UpdateDisplay(hwndDlg, pGlobalData, bUpdateThumb);
+ pData->CurrentDisplayDevice->CurrentSettings = Current;
+ UpdateDisplay(hwndDlg, pData, bUpdateThumb);
return;
}
Current = Current->Blink;
{
if (Current->dmPelsHeight == dmNewPelsHeight
&& Current->dmPelsWidth == dmNewPelsWidth
- && Current->dmBitsPerPel == pGlobalData->CurrentDisplayDevice->CurrentSettings->dmBitsPerPel)
+ && Current->dmBitsPerPel == pData->CurrentDisplayDevice->CurrentSettings->dmBitsPerPel)
{
- pGlobalData->CurrentDisplayDevice->CurrentSettings = Current;
- UpdateDisplay(hwndDlg, pGlobalData, bUpdateThumb);
+ pData->CurrentDisplayDevice->CurrentSettings = Current;
+ UpdateDisplay(hwndDlg, pData, bUpdateThumb);
return;
}
Current = Current->Flink;
}
/* search bigger color depth compatible with current resolution */
- Current = pGlobalData->CurrentDisplayDevice->CurrentSettings->Flink;
+ Current = pData->CurrentDisplayDevice->CurrentSettings->Flink;
while (Current != NULL)
{
if (dmNewPelsHeight == Current->dmPelsHeight && dmNewPelsWidth == Current->dmPelsWidth)
{
- pGlobalData->CurrentDisplayDevice->CurrentSettings = Current;
- UpdateDisplay(hwndDlg, pGlobalData, bUpdateThumb);
+ pData->CurrentDisplayDevice->CurrentSettings = Current;
+ UpdateDisplay(hwndDlg, pData, bUpdateThumb);
return;
}
Current = Current->Flink;
}
/* search smaller color depth compatible with current resolution */
- Current = pGlobalData->CurrentDisplayDevice->CurrentSettings->Blink;
+ Current = pData->CurrentDisplayDevice->CurrentSettings->Blink;
while (Current != NULL)
{
if (dmNewPelsHeight == Current->dmPelsHeight && dmNewPelsWidth == Current->dmPelsWidth)
{
- pGlobalData->CurrentDisplayDevice->CurrentSettings = Current;
- UpdateDisplay(hwndDlg, pGlobalData, bUpdateThumb);
+ pData->CurrentDisplayDevice->CurrentSettings = Current;
+ UpdateDisplay(hwndDlg, pData, bUpdateThumb);
return;
}
Current = Current->Blink;
INT_PTR CALLBACK
SettingsPageProc(IN HWND hwndDlg, IN UINT uMsg, IN WPARAM wParam, IN LPARAM lParam)
{
- PGLOBAL_DATA pGlobalData;
+ PDATA pData;
+ TCHAR Message[1024], Title[256];
- pGlobalData = (PGLOBAL_DATA)GetWindowLongPtr(hwndDlg, DWLP_USER);
+ pData = (PDATA)GetWindowLongPtr(hwndDlg, DWLP_USER);
switch(uMsg)
{
lpDrawItem = (LPDRAWITEMSTRUCT) lParam;
if (lpDrawItem->CtlID == IDC_SETTINGS_SPECTRUM)
- ShowColorSpectrum(lpDrawItem->hDC, &lpDrawItem->rcItem, pGlobalData->CurrentDisplayDevice->CurrentSettings->dmBitsPerPel, pGlobalData);
-
+ ShowColorSpectrum(lpDrawItem->hDC, &lpDrawItem->rcItem, pData->CurrentDisplayDevice->CurrentSettings->dmBitsPerPel, pData);
break;
}
case WM_COMMAND:
DWORD command = HIWORD(wParam);
if (controlId == IDC_SETTINGS_ADVANCED && command == BN_CLICKED)
- DisplayAdvancedSettings(hwndDlg, pGlobalData->CurrentDisplayDevice);
+ DisplayAdvancedSettings(hwndDlg, pData->CurrentDisplayDevice);
else if (controlId == IDC_SETTINGS_BPP && command == CBN_SELCHANGE)
- OnBPPChanged(hwndDlg, pGlobalData);
+ OnBPPChanged(hwndDlg, pData);
break;
}
case WM_HSCROLL:
case TB_ENDTRACK:
{
DWORD newPosition = (DWORD) SendDlgItemMessage(hwndDlg, IDC_SETTINGS_RESOLUTION, TBM_GETPOS, 0, 0);
- OnResolutionChanged(hwndDlg, pGlobalData, newPosition, TRUE);
+ OnResolutionChanged(hwndDlg, pData, newPosition, TRUE);
break;
}
case TB_THUMBTRACK:
- OnResolutionChanged(hwndDlg, pGlobalData, HIWORD(wParam), FALSE);
+ OnResolutionChanged(hwndDlg, pData, HIWORD(wParam), FALSE);
break;
}
break;
LPNMHDR lpnm = (LPNMHDR)lParam;
if (lpnm->code == (UINT)PSN_APPLY)
{
- if (pGlobalData->CurrentDisplayDevice->CurrentSettings->dmPelsWidth != pGlobalData->CurrentDisplayDevice->InitialSettings.dmPelsWidth
- || pGlobalData->CurrentDisplayDevice->CurrentSettings->dmPelsHeight != pGlobalData->CurrentDisplayDevice->InitialSettings.dmPelsHeight
- || pGlobalData->CurrentDisplayDevice->CurrentSettings->dmBitsPerPel != pGlobalData->CurrentDisplayDevice->InitialSettings.dmBitsPerPel)
+ if (pData->CurrentDisplayDevice->CurrentSettings->dmPelsWidth != pData->CurrentDisplayDevice->InitialSettings.dmPelsWidth
+ || pData->CurrentDisplayDevice->CurrentSettings->dmPelsHeight != pData->CurrentDisplayDevice->InitialSettings.dmPelsHeight
+ || pData->CurrentDisplayDevice->CurrentSettings->dmBitsPerPel != pData->CurrentDisplayDevice->InitialSettings.dmBitsPerPel)
{
/* FIXME: Need to test changes */
/* Apply new settings */
DEVMODE devmode;
RtlZeroMemory(&devmode, sizeof(DEVMODE));
devmode.dmSize = (WORD)sizeof(DEVMODE);
- devmode.dmPelsWidth = pGlobalData->CurrentDisplayDevice->CurrentSettings->dmPelsWidth;
- devmode.dmPelsHeight = pGlobalData->CurrentDisplayDevice->CurrentSettings->dmPelsHeight;
- devmode.dmBitsPerPel = pGlobalData->CurrentDisplayDevice->CurrentSettings->dmBitsPerPel;
- devmode.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT | DM_BITSPERPEL;
+ devmode.dmPelsWidth = pData->CurrentDisplayDevice->CurrentSettings->dmPelsWidth;
+ devmode.dmPelsHeight = pData->CurrentDisplayDevice->CurrentSettings->dmPelsHeight;
+ devmode.dmBitsPerPel = pData->CurrentDisplayDevice->CurrentSettings->dmBitsPerPel;
+ devmode.dmDisplayFrequency = pData->CurrentDisplayDevice->CurrentSettings->dmDisplayFrequency;
+ devmode.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT | DM_BITSPERPEL | DM_DISPLAYFREQUENCY;
rc = ChangeDisplaySettingsEx(
- pGlobalData->CurrentDisplayDevice->DeviceName,
+ pData->CurrentDisplayDevice->DeviceName,
&devmode,
NULL,
CDS_UPDATEREGISTRY,
switch (rc)
{
case DISP_CHANGE_SUCCESSFUL:
- pGlobalData->CurrentDisplayDevice->InitialSettings.dmPelsWidth = pGlobalData->CurrentDisplayDevice->CurrentSettings->dmPelsWidth;
- pGlobalData->CurrentDisplayDevice->InitialSettings.dmPelsHeight = pGlobalData->CurrentDisplayDevice->CurrentSettings->dmPelsHeight;
- pGlobalData->CurrentDisplayDevice->InitialSettings.dmBitsPerPel = pGlobalData->CurrentDisplayDevice->CurrentSettings->dmBitsPerPel;
- break;
- case DISP_CHANGE_FAILED:
- MessageBox(NULL, TEXT("Failed to apply new settings..."), TEXT("Display settings"), MB_OK | MB_ICONSTOP);
+ pData->CurrentDisplayDevice->InitialSettings.dmPelsWidth = pData->CurrentDisplayDevice->CurrentSettings->dmPelsWidth;
+ pData->CurrentDisplayDevice->InitialSettings.dmPelsHeight = pData->CurrentDisplayDevice->CurrentSettings->dmPelsHeight;
+ pData->CurrentDisplayDevice->InitialSettings.dmBitsPerPel = pData->CurrentDisplayDevice->CurrentSettings->dmBitsPerPel;
break;
case DISP_CHANGE_RESTART:
- MessageBox(NULL, TEXT("You need to restart your computer to apply changes."), TEXT("Display settings"), MB_OK | MB_ICONINFORMATION);
+ LoadString(hApplet, IDS_DISPLAY_SETTINGS, Title, sizeof(Title) / sizeof(TCHAR));
+ LoadString(hApplet, IDS_APPLY_NEEDS_RESTART, Message, sizeof(Message) / sizeof (TCHAR));
+ MessageBox(hwndDlg, Message, Title, MB_OK | MB_ICONINFORMATION);
break;
+ case DISP_CHANGE_FAILED:
default:
- MessageBox(NULL, TEXT("Unknown error when applying new settings..."), TEXT("Display settings"), MB_OK | MB_ICONSTOP);
+ LoadString(hApplet, IDS_DISPLAY_SETTINGS, Title, sizeof(Title) / sizeof(TCHAR));
+ LoadString(hApplet, IDS_APPLY_FAILED, Message, sizeof(Message) / sizeof (TCHAR));
+ MessageBox(hwndDlg, Message, Title, MB_OK | MB_ICONSTOP);
break;
}
}
case WM_DESTROY:
{
- INT i;
- PDISPLAY_DEVICE_ENTRY Current = pGlobalData->DisplayDeviceList;
+ DWORD i;
+ PDISPLAY_DEVICE_ENTRY Current = pData->DisplayDeviceList;
while (Current != NULL)
{
Current = Next;
}
- HeapFree(GetProcessHeap(), 0, pGlobalData);
-
for (i = 0; i < NUM_SPECTRUM_BITMAPS; i++)
{
- if (pGlobalData->hSpectrumBitmaps[i])
- DeleteObject(pGlobalData->hSpectrumBitmaps[i]);
+ if (pData->hSpectrumBitmaps[i])
+ DeleteObject(pData->hSpectrumBitmaps[i]);
}
+
+ HeapFree(GetProcessHeap(), 0, pData);
}
}
return FALSE;