Reputation: 373
I would like to create a custom page with combo box, that will contain all available display resolutions and color modes. I've found this example for Delphi, but the TDevmode
class is not supported in InnoSetup as far as I know.
Can anyone show, how to fill a combo box only with 16-bit and 32-bit color display modes ?
Example:
1024 x 768 16 Bit
1024 x 768 32 Bit
Upvotes: 2
Views: 446
Reputation: 76713
Try this:
[Setup]
AppName=My Program
AppVersion=1.5
DefaultDirName={pf}\My Program
OutputDir=userdocs:Inno Setup Examples Output
[Code]
#ifdef UNICODE
#define AW "W"
#else
#define AW "A"
#endif
const
CCHFORMNAME = 32;
CCHDEVICENAME = 32;
type
TDeviceMode = record
dmDeviceName: array[0..CCHDEVICENAME - 1] of Char;
dmSpecVersion: Word;
dmDriverVersion: Word;
dmSize: Word;
dmDriverExtra: Word;
dmFields: DWORD;
dmOrientation: Smallint;
dmPaperSize: Smallint;
dmPaperLength: Smallint;
dmPaperWidth: Smallint;
dmScale: Smallint;
dmCopies: Smallint;
dmDefaultSource: Smallint;
dmPrintQuality: Smallint;
dmColor: Smallint;
dmDuplex: Smallint;
dmYResolution: Smallint;
dmTTOption: Smallint;
dmCollate: Smallint;
dmFormName: array[0..CCHFORMNAME - 1] of Char;
dmLogPixels: Word;
dmBitsPerPel: DWORD;
dmPelsWidth: DWORD;
dmPelsHeight: DWORD;
dmDisplayFlags: DWORD;
dmDisplayFrequency: DWORD;
dmICMMethod: DWORD;
dmICMIntent: DWORD;
dmMediaType: DWORD;
dmDitherType: DWORD;
dmICCManufacturer: DWORD;
dmICCModel: DWORD;
dmPanningWidth: DWORD;
dmPanningHeight: DWORD;
end;
TDeviceFilter = record
Width: DWORD;
Height: DWORD;
BitDepth: DWORD;
end;
function EnumDisplaySettings(lpszDeviceName: string; iModeNum: DWORD;
var lpDevMode: TDeviceMode): BOOL;
external 'EnumDisplaySettings{#AW}@user32.dll stdcall';
procedure InitializeWizard;
var
ModeIndex: DWORD;
ModeExists: Boolean;
FilterIndex: Integer;
DisplayPage: TWizardPage;
DisplayCombo: TNewComboBox;
DisplayModes: array of TDeviceFilter;
DisplaySettings: TDeviceMode;
begin
DisplayPage := CreateCustomPage(wpWelcome, 'Caption', 'Description');
DisplayCombo := TNewComboBox.Create(WizardForm);
DisplayCombo.Parent := DisplayPage.Surface;
DisplayCombo.Style := csDropDownList;
DisplayCombo.Width := 200;
ModeIndex := 0;
while EnumDisplaySettings('', ModeIndex, DisplaySettings) do
begin
with DisplaySettings do
begin
Inc(ModeIndex);
if (dmBitsperPel <> 16) and (dmBitsperPel <> 32) then
Continue;
ModeExists := False;
for FilterIndex := 0 to GetArrayLength(DisplayModes) - 1 do
begin
if (DisplayModes[FilterIndex].Width = dmPelsWidth) and
(DisplayModes[FilterIndex].Height = dmPelsHeight) and
(DisplayModes[FilterIndex].BitDepth = dmBitsperPel) then
begin
ModeExists := True;
Break;
end;
end;
if not ModeExists then
begin
SetArrayLength(DisplayModes, GetArrayLength(DisplayModes) + 1);
with DisplayModes[GetArrayLength(DisplayModes) - 1] do
begin
Width := dmPelsWidth;
Height := dmPelsHeight;
BitDepth := dmBitsperPel;
DisplayCombo.Items.Add(Format('%dx%d %d bpp', [Width,
Height, BitDepth]));
end;
end;
end;
end;
end;
Upvotes: 2