/ / TInputQueryWizardPageの編集ボックスに英数字のみを入力する方法は? - inno-setup

TInputQueryWizardPageの編集ボックスに英数字のみを入力する方法は? - inno-setup

私はInno Setupの英数字のみを入力できるようにする必要があります TInputQueryWizardPage 編集ボックス。これどうやってするの ?

回答:

回答№1の場合は3

英数字の文字を認識するためには、 IsCharAlphaNumeric Windows API関数と割り当てられた入力編集で OnKeyPress イベント私はそれが英数字でなければ、キーを食べるだろう:

[Setup]
AppName=My Program
AppVersion=1.5
DefaultDirName={pf}My Program

[Code]
#ifdef UNICODE
#define AW "W"
#else
#define AW "A"
#endif

function IsCharAlphaNumeric(ch: Char): BOOL;
external "IsCharAlphaNumeric{#AW}@user32.dll stdcall";

procedure InputQueryEditKeyPress(Sender: TObject; var Key: Char);
begin
// if the currently pressed key is not alphanumeric, eat it by
// assigning #0 value
if not IsCharAlphaNumeric(Key) then
Key := #0;
end;

procedure InitializeWizard;
var
EditIndex: Integer;
InputPage: TInputQueryWizardPage;
begin
// create input query page and add one edit item
InputPage := CreateInputQueryPage(wpWelcome, "Caption", "Description",
"SubCaption");
EditIndex := InputPage.Add("Name:", False);
// assign the OnKeyPress event method to our custom one
InputPage.Edits[EditIndex].OnKeyPress := @InputQueryEditKeyPress;
end;