⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sellangform.pas

📁 源代码
💻 PAS
字号:
unit SelLangForm;

{
  Inno Setup
  Copyright (C) 1997-2004 Jordan Russell
  Portions by Martijn Laan
  For conditions of distribution and use, see LICENSE.TXT.

  "Select Language" form

  $jrsoftware: issrc/Projects/SelLangForm.pas,v 1.14 2004/07/02 20:05:54 jr Exp $
}

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  SetupForm, StdCtrls, ExtCtrls, NewStaticText, BitmapImage;

type
  TSelectLanguageForm = class(TSetupForm)
    SelectLabel: TNewStaticText;
    LangCombo: TComboBox;
    OKButton: TButton;
    CancelButton: TButton;
    IconBitmapImage: TBitmapImage;
  private
    { Private declarations }
  public
    { Public declarations }
    constructor Create(AOwner: TComponent); override;
  end;

function AskForLanguage: Boolean;

implementation

uses
  Struct, Msgs, MsgIDs, Main;

{$R *.DFM}

var
  DefComboWndProcW, PrevComboWndProc: Pointer;

function NewComboWndProc(Wnd: HWND; Msg: UINT; wParam: WPARAM; lParam: LPARAM): LRESULT;
stdcall;
begin
  case Msg of
    { CB_ADDSTRING must pass to the default Unicode combo box window procedure
      since PrevWndProc is an ANSI window procedure and calling it would result
      in Unicode->ANSI conversion. Do the same for CB_GETLBTEXT(LEN) so that
      MSAA sees Unicode strings. }
    CB_ADDSTRING, CB_GETLBTEXT, CB_GETLBTEXTLEN:
      Result := CallWindowProcW(DefComboWndProcW, Wnd, Msg, wParam, lParam)
  else
    Result := CallWindowProcW(PrevComboWndProc, Wnd, Msg, wParam, lParam);
  end;
end;

function AskForLanguage: Boolean;
{ Creates and shows the "Select Language" dialog. Returns True and activates
  the selected language if the user clicks OK, or False otherwise. }
var
  LangForm: TSelectLanguageForm;
  ClassInfo: TWndClassW;
  I, J: Integer;
  LangEntry: PSetupLanguageEntry;
  N: String;
begin
  LangForm := TSelectLanguageForm.Create(Application);
  try
    { On NT, make it possible to add Unicode strings to our ANSI combo box by
      installing a window procedure with special CB_ADDSTRING handling.
      Yeah, this is a hack; it's too hard to create a native Unicode control
      in Delphi. }
    if Win32Platform = VER_PLATFORM_WIN32_NT then begin
      if GetClassInfoW(0, 'COMBOBOX', ClassInfo) then begin
        DefComboWndProcW := ClassInfo.lpfnWndProc;
        Longint(PrevComboWndProc) := SetWindowLongW(LangForm.LangCombo.Handle,
          GWL_WNDPROC, Longint(@NewComboWndProc));
      end;
    end;

    for I := 0 to Entries[seLanguage].Count-1 do begin
      LangEntry := Entries[seLanguage][I];
      if (I = ActiveLanguage) or (LangEntry.LanguageCodePage = 0) or
         (LangEntry.LanguageCodePage = GetACP) then begin
        { Note: LanguageName is Unicode }
        N := LangEntry.LanguageName + #0#0;  { need wide null! }
        if Win32Platform = VER_PLATFORM_WIN32_NT then
          J := SendMessageW(LangForm.LangCombo.Handle, CB_ADDSTRING, 0,
            Longint(PWideChar(Pointer(N))))
        else
          J := LangForm.LangCombo.Items.Add(WideCharToString(PWideChar(Pointer(N))));
        if J >= 0 then
          LangForm.LangCombo.Items.Objects[J] := TObject(I);
      end;
    end;
    LangForm.LangCombo.ItemIndex := LangForm.LangCombo.Items.IndexOfObject(TObject(ActiveLanguage));

    if LangForm.LangCombo.Items.Count > 1 then begin
      Result := (LangForm.ShowModal = mrOK);
      if Result then begin
        I := LangForm.LangCombo.ItemIndex;
        if I >= 0 then
          SetActiveLanguage(Integer(LangForm.LangCombo.Items.Objects[I]));
      end;
    end
    else begin
      { Don't show language dialog if there aren't multiple languages to choose
        from, which can happen if only one language matches the user's code
        page. }
      Result := True;
    end;
  finally
    LangForm.Free;
  end;
end;

{ TSelectLanguageForm }

constructor TSelectLanguageForm.Create(AOwner: TComponent);
begin
  inherited;

  InitializeFont;
  Center;

  Caption := SetupMessages[msgSelectLanguageTitle];
  SelectLabel.Caption := SetupMessages[msgSelectLanguageLabel];
  OKButton.Caption := SetupMessages[msgButtonOK];
  CancelButton.Caption := SetupMessages[msgButtonCancel];

  IconBitmapImage.Bitmap.Canvas.Brush.Color := Color;
  IconBitmapImage.Bitmap.Width := Application.Icon.Width;
  IconBitmapImage.Bitmap.Height := Application.Icon.Height;
  IconBitmapImage.Bitmap.Canvas.Draw(0, 0, Application.Icon);
  IconBitmapImage.Width := IconBitmapImage.Bitmap.Width;
  IconBitmapImage.Height := IconBitmapImage.Bitmap.Height;
end;

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -