2014-04-22 79 views

回答

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; 
+0

感谢TLama,代码工作正常。 – user1752602

+0

不客气! – TLama

相关问题