2

我想创建一个带有组合框的自定义页面,它将包含所有可用的显示分辨率和颜色模式。我为 Delphi 找到了这个示例,但TDevmode据我所知, InnoSetup 不支持该类。

谁能展示一下,如何仅使用 16 位和 32 位彩色显示模式填充组合框?

例子:

1024 x 768 16 Bit
1024 x 768 32 Bit
4

1 回答 1

2

试试这个:

[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;
于 2012-12-03T08:31:36.300 回答