在Inno Setup中,如果用户输入文本是无效值,我想以红色显示。 (由我在其他地方确定。)
答案 0 :(得分:2)
您将设置所选编辑的Font.Color
属性。例如,要在文本更改时立即更改编辑字体颜色,您可以为OnChange
事件编写处理程序,在代码中可能是这样的:
[Setup]
AppName=My Program
AppVersion=1.5
DefaultDirName={pf}\My Program
[Code]
var
CustomEdit: TNewEdit;
procedure CustomEditChange(Sender: TObject);
begin
if Sender is TEdit then
begin
// the font color will be changed to red when the user enters more
// than 3 chars in the edit, to default color otherwise; rules for
// this statement are upon you
if Length(TEdit(Sender).Text) > 3 then
TEdit(Sender).Font.Color := clRed
else
TEdit(Sender).Font.Color := clWindowText;
end;
end;
procedure InitializeWizard;
var
CustomPage: TWizardPage;
begin
CustomPage := CreateCustomPage(wpWelcome, 'Caption', 'Description');
CustomEdit := TNewEdit.Create(CustomPage);
CustomEdit.Parent := CustomPage.Surface;
CustomEdit.OnChange := @CustomEditChange;
end;
如果您想在用户退出编辑框时验证输入,您可以为OnExit
事件编写类似的处理程序。