Blog
All Blog Posts | Next Post | Previous PostFriendly balloon hints for entry via TAdvInputTaskDialog
Thursday, April 30, 2020
The TaskDialog API was introduced in the Microsoft Windows Vista operating system as a more user-friendly way to give notifications to users. Where a MessageBox() only has a caption, text, icon and buttons, the task dialog introduced additional expanded text, options to select from, checkbox to select to show the message again in the future or not etc...
When the Windows Vista TaskDialog appeared, TMS was the first to embrace it and make a component that not only used this API on Windows Vista or newer operating systems, but also emulated the API on operating systems older than Windows Vista so it would be useful everywhere opposed to applications using only the Microsoft API and thereby making the application minimum requirement Windows Vista or newer.
But we did not only that, we extended the capabilities offering that the dialog could also capture inputs rather than just show a message and wrapped this in the component TAdvInputTaskDialog. Inputs can be captured using various control types:
- itEdit: regular TEdit is used
- itMemo: regular TMemo is used
- itComboEdit: a TComboBox in csDropDown style is used
- itComboList: a TComboBox in csDropDownList style is used
- itDate: a TDateTimePicker in dtkDate kind
- itCustom: any custom VCL control can be used for input
- itNone: no input is possible
- itTime: a TDateTimePicker in dtkTime kind
- itPassword: a TEdit with password style is used
And recently, we went a step further. We added a friendly way to validate input when the user wants to close the input dialog and show a Windows balloon hint with information when the input is not considered valid. To do this, implement the TAdvInputTaskDialog.OnValidateInputText() event handler. This event handler returns the entered text and has an IsValid parameter that can be used to allow the dialog to close or not. Now, with the properties AdvInputTaskDialog.InvalidEntryTitle, AdvInputTaskDialog.InvalidEntryText, AdvInputTaskDialog.InvalidEntryIcon we can specify what the balloon hint should display when the input is not considered valid.
How this works is shown in two samples below.
The first sample is for a capturing an email address with the validation that the user only enters a qualifying email address. We use the Delphi regular expressions component TRegEx to perform this validation and set the balloon hint info when the entry is not a valid email address:
procedure TForm1.Button1Click(Sender: TObject); begin AdvInputTaskDialog1.Title := 'Enter email address'; AdvInputTaskDialog1.Content := 'Email:'; AdvInputTaskDialog1.Icon := tiShield; AdvInputTaskDialog1.ExpandedDefault := true; AdvInputTaskDialog1.ExpandedText := 'Your email address will be used to login'; AdvInputTaskDialog1.Execute; end;
procedure TForm1.AdvInputTaskDialog1ValidateInputText(Sender: TObject; var NewValue: string; const Data, ModalResult: Integer; var IsValid: Boolean); begin isValid := TRegEx.IsMatch(NewValue, '^([a-zA-Z0-9_-.]+)@([a-zA-Z0-9_-.]+).([a-zA-Z]{2,5})$'); if not isValid then begin AdvInputTaskDialog1.InvalidEntryTitle := 'Input error'; AdvInputTaskDialog1.InvalidEntryText := 'Value entered is not a valid email address'; AdvInputTaskDialog1.InvalidEntryIcon := tieError; end; end;
The second sample is for a capturing a password that needs to meet specific security requirements. As this concerns a password entry where the password is not supposed to be visible on the screen, the TAdvInputTaskDialog.InputType is set to itPassword. Also here we use the Delphi regular expressions component TRegEx to perform this validation and set the balloon hint info when the entry is not a valid email address:
procedure TForm1.Button2Click(Sender: TObject); begin AdvInputTaskDialog2.Title := 'Enter a new password'; AdvInputTaskDialog2.Content := 'Password:'; AdvInputTaskDialog2.Icon := tiQuestion; AdvInputTaskDialog2.InputType := itPassword; AdvInputTaskDialog2.ExpandedDefault := true; AdvInputTaskDialog2.ExpandedText := 'The password must'#13 + ' - have a lengh greater than or equal to 8'#13 + '- contain one or more uppercase characters'#13 + '- contain one or more lowercase characters'#13 + '- contain one or more numeric values'#13 + '- contain one or more special characters'; AdvInputTaskDialog2.Execute; end;
procedure TForm1.AdvInputTaskDialog2ValidateInputText(Sender: TObject; var NewValue: string; const Data, ModalResult: Integer; var IsValid: Boolean); begin isValid := TRegEx.IsMatch(NewValue, '(?=^.{8,}$)(?=.*d)(?=.*[!@#$%^&*]+)(?![. ])(?=.*[A-Z])(?=.*[a-z]).*$'); if not isValid then begin AdvInputTaskDialog2.InvalidEntryTitle := 'Invalid password'; AdvInputTaskDialog2.InvalidEntryText := 'Please enter a password meeting the security requirements'; AdvInputTaskDialog2.InvalidEntryIcon := tieError; end; end;
TAdvInputTaskDialog with balloon hints is available in the latest TMS VCL UI Pack (the successor of TMS Component Pack) along with over 400 other powerful VCL user-interface components to make your Delphi Windows applications shine!
You can get the trial version to find out for yourself and note that when you are a student, we have a free academic version!
Bruno Fierens
This blog post has received 12 comments.
2. Thursday, April 30, 2020 at 12:16:37 PM
FNC components are designed to be used in FMX applications
Bruno Fierens
3. Thursday, April 30, 2020 at 10:55:01 PM
I understand that FNC components are designed to be used in FMX applications! But, no one will exchange the purchased TMS FMX Component components for FNC! It’s unfair like that ...
LATYSHEV VADIM
4. Friday, May 1, 2020 at 9:44:01 AM
1) FNC is an additional choice for FMX application developers
2) FNC can be used together with other existing FMX components, it does not force anyone to exchange these
3) Our FMX components are still supported for current and future Delphi versions
2) FNC can be used together with other existing FMX components, it does not force anyone to exchange these
3) Our FMX components are still supported for current and future Delphi versions
Bruno Fierens
5. Friday, May 1, 2020 at 10:22:51 PM
If I use Lazarus and only FNC (that means no using VCL and FMX), does it works for there platforms?
stlcours
6. Saturday, May 2, 2020 at 9:10:45 AM
1). Yes
2). Yes
3). FMX is supported, I agree. But I mean, it''s not developing! Do you feel the difference?
2). Yes
3). FMX is supported, I agree. But I mean, it''s not developing! Do you feel the difference?
LATYSHEV VADIM
7. Saturday, May 2, 2020 at 10:15:40 AM
3) I invite you to learn how much effort it costs to keep this product actual with updates of all operating systems it supports and the evolutions (with each time breaking changes) in the FireMonkey framework. Yet, regardless of this effort (thus cost), we keep supporting this product at basically the same low price for years already.
Other than this, the content of this thread does not contribute any value to the technical content of the article concerning a VCL product, a product we support for 25 years now. So please consider this the final answer.
Other than this, the content of this thread does not contribute any value to the technical content of the article concerning a VCL product, a product we support for 25 years now. So please consider this the final answer.
Bruno Fierens
8. Saturday, May 2, 2020 at 10:44:57 AM
@stlcours : We test & validate FNC components on Lazarus on Windows and Linux
Bruno Fierens
9. Sunday, May 23, 2021 at 11:30:21 AM
When AdvInputTaskDialog.InputType = itEdit, how to force the TEdit to accept only numbers?
Aschbacher Peter
10. Sunday, May 23, 2021 at 11:44:00 AM
I found the ssolution:
procedure TMainForm.AdvInputTaskDialog1DialogCreated(Sender: TObject);
begin AdvInputTaskDialog1.DialogForm.InputEdit.NumbersOnly := True;
end;
procedure TMainForm.AdvInputTaskDialog1DialogCreated(Sender: TObject);
begin AdvInputTaskDialog1.DialogForm.InputEdit.NumbersOnly := True;
end;
Aschbacher Peter
11. Sunday, May 23, 2021 at 11:57:25 AM
... But why TAdvInputTaskDialog.DialogForm.InputEdit is TEdit type and not TAdvEdit? TAdvEdit would offer more possiblities.
Aschbacher Peter
12. Tuesday, May 25, 2021 at 4:50:52 PM
TAdvEdit can be used as custom input control. Your question in this respect was followed-up via our support channel where technical support discussions like this belong.
Bruno Fierens
All Blog Posts | Next Post | Previous Post
What about the components for the FMX? Are they abandoned?
LATYSHEV VADIM