在Inno Setup中,如何设置输入字段中文本的文本颜色? [英] In Inno Setup, how can I set the text color of the text in an input field?
本文介绍了在Inno Setup中,如何设置输入字段中文本的文本颜色?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在Inno设置中,如果用户输入的文本无效,则要用红色显示。 (由我决定,在其他地方。)
In Inno Setup, I want to display the user input text in red if it is an invalid value. (As determined by me, elsewhere.)
推荐答案
您将设置 Font.Color
您选择的修改的属性。例如,要在文本更改时立即更改编辑字体的颜色,可以为 OnChange
事件编写一个处理程序,在代码中可能是这样的:
You are going to set the Font.Color
property of the edit of your choice. For instance, to change the edit font color immediately when the text changes, you can write a handler for the OnChange
event, in code it might be something like this:
[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;
如果您希望在用户退出编辑框时验证输入,则可以为<$编写类似的处理程序c $ c> OnExit 事件。
If you would like to validate the input when the user exits the edit box, you can write similar handler for the OnExit
event.
这篇关于在Inno Setup中,如何设置输入字段中文本的文本颜色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文