mirror of
https://github.com/reactos/reactos.git
synced 2025-08-02 05:55:42 +00:00
Don't crash when no working display adapter is present
svn path=/trunk/; revision=22206
This commit is contained in:
parent
cc12e88784
commit
c373b8ba66
1 changed files with 69 additions and 69 deletions
|
@ -1,12 +1,11 @@
|
|||
/* $Id$
|
||||
*
|
||||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS Display Control Panel
|
||||
* FILE: lib/cpl/desk/settings.c
|
||||
* PURPOSE: Settings property page
|
||||
*
|
||||
* PROGRAMMERS: Trevor McCort (lycan359@gmail.com)
|
||||
* Hervé Poussineau (poussine@freesurf.fr)
|
||||
* Hervé Poussineau (hpoussin@reactos.org)
|
||||
*/
|
||||
|
||||
#include "desk.h"
|
||||
|
@ -59,7 +58,6 @@ UpdateDisplay(IN HWND hwndDlg)
|
|||
_stprintf(Buffer, Pixel, CurrentDisplayDevice->CurrentSettings->dmPelsWidth, CurrentDisplayDevice->CurrentSettings->dmPelsHeight, Pixel);
|
||||
SendDlgItemMessage(hwndDlg, IDC_SETTINGS_RESOLUTION_TEXT, WM_SETTEXT, 0, (LPARAM)Buffer);
|
||||
|
||||
|
||||
for (index = 0; index < CurrentDisplayDevice->ResolutionsCount; index++)
|
||||
{
|
||||
|
||||
|
@ -100,7 +98,6 @@ GetPossibleSettings(IN LPTSTR DeviceName, OUT DWORD* pSettingsCount, OUT PSETTIN
|
|||
devmode.dmDriverExtra = 0;
|
||||
while (EnumDisplaySettingsEx(DeviceName, iMode, &devmode, dwFlags))
|
||||
{
|
||||
|
||||
if (devmode.dmBitsPerPel==8 || devmode.dmBitsPerPel==16 || devmode.dmBitsPerPel==24 || devmode.dmBitsPerPel==32) checkbpp=1;
|
||||
else checkbpp=0;
|
||||
|
||||
|
@ -151,7 +148,7 @@ GetPossibleSettings(IN LPTSTR DeviceName, OUT DWORD* pSettingsCount, OUT PSETTIN
|
|||
return Settings;
|
||||
}
|
||||
|
||||
static VOID
|
||||
static BOOL
|
||||
AddDisplayDevice(IN LPTSTR Description, IN LPTSTR DeviceName)
|
||||
{
|
||||
PDISPLAY_DEVICE_ENTRY newEntry = NULL;
|
||||
|
@ -164,6 +161,7 @@ AddDisplayDevice(IN LPTSTR Description, IN LPTSTR DeviceName)
|
|||
DWORD i;
|
||||
|
||||
newEntry = HeapAlloc(GetProcessHeap(), 0, sizeof(DISPLAY_DEVICE_ENTRY));
|
||||
memset(newEntry, 0, sizeof(DISPLAY_DEVICE_ENTRY));
|
||||
if (!newEntry) goto ByeBye;
|
||||
|
||||
newEntry->Settings = GetPossibleSettings(DeviceName, &newEntry->SettingsCount, &newEntry->CurrentSettings);
|
||||
|
@ -205,7 +203,7 @@ AddDisplayDevice(IN LPTSTR Description, IN LPTSTR DeviceName)
|
|||
newEntry->DeviceName = name;
|
||||
newEntry->Flink = DisplayDeviceList;
|
||||
DisplayDeviceList = newEntry;
|
||||
return;
|
||||
return TRUE;
|
||||
|
||||
ByeBye:
|
||||
if (newEntry != NULL)
|
||||
|
@ -228,6 +226,7 @@ ByeBye:
|
|||
HeapFree(GetProcessHeap(), 0, description);
|
||||
if (name != NULL)
|
||||
HeapFree(GetProcessHeap(), 0, name);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static VOID
|
||||
|
@ -275,7 +274,7 @@ OnInitDialog(IN HWND hwndDlg)
|
|||
{
|
||||
if ((displayDevice.StateFlags & DISPLAY_DEVICE_ATTACHED_TO_DESKTOP) != 0)
|
||||
{
|
||||
AddDisplayDevice(displayDevice.DeviceString, displayDevice.DeviceName);
|
||||
if (AddDisplayDevice(displayDevice.DeviceString, displayDevice.DeviceName))
|
||||
Result++;
|
||||
}
|
||||
iDevNum++;
|
||||
|
@ -587,7 +586,8 @@ SettingsPageProc(IN HWND hwndDlg, IN UINT uMsg, IN WPARAM wParam, IN LPARAM lPar
|
|||
DeleteDC(hdcMem);
|
||||
EndPaint(hwndDlg, &ps);
|
||||
|
||||
} break;
|
||||
break;
|
||||
}
|
||||
|
||||
case WM_DESTROY:
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue