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 に答える