RAD Studio VCL Reference
|
Specifies the text string that appears in the Help Hint box.
property Hint: string;
__property AnsiString Hint;
TApplication's Hint property is assigned the Hint value of the control or menu item that the mouse is currently moving over. It can also be assigned a string value that informs the user of some action, error, or other type of information. Therefore, use Hint either to:
Transfer hints from controls to another area of display, such as a status bar, using the OnHint event handler. This reads the Hint property.
Indicate the status of the application while it is processing some action. This sets the Hint property.
Help Hints appear when the OnHint event occurs. Therefore, if TApplication's Hint property is assigned to the status bar's caption, for example, the caption of the status bar control displays the current string value of the Hint property during an OnHint event.
There are two parts to the Hint string: short and long. Short hints are used by pop-up tool tips. Long hints are used by the status bar, separated by the | character. Use the global functions GetShortHint and GetLongHint, from the Controls unit to extract the long and short hints from a hint string.
C++ Examples:
/* This example uses an edit box and a list box on a form. Items are added to the list box and a Help Hint is assigned to both controls. The last statement enables the Help Hints for the entire application. */ void __fastcall TForm1::FormCreate(TObject *Sender) { Edit1->Hint = "Enter your name"; Edit1->ShowHint = true; char string[10]; char index[3]; for(int i = 1; i <= 10; i++) { strcpy(string, "Item"); itoa(i, index, 10); strcat(string, index); ListBox1->Items->Add(string); } ListBox1->Hint = "Select an item"; ListBox1->ShowHint = true; Application->ShowHint = true; } /* Note: To see an example that displays the hints of controls in some place other than in a Help Hint box, see the OnHint example. */
/* Note: It is not actually necessary to write an OnHint event handler to display hints on the status bar. This can be accomplished more simply by setting the status bar’s AutoHint property and SimplePanel property. This shows how the OnHint event handler is declared as a public method of the form. */ /* Here is the code to add to the unit file. It provides the implementation of the DisplayHint method and assigns it to the Application in the form’s OnCreate event handler. Note: It is not actually necessary to write an OnHint event handler to display hints on the status bar. This can be accomplished more simply by setting the status bar’s AutoHint property. */ void __fastcall TForm1::DisplayHint(TObject *Sender) { StatusBar1->SimpleText = GetLongHint(Application->Hint); } // Here is the form’s OnCreate event handler. // It assigns the application’s OnHint event handler at // runtime because the Application is not available in the // Object Inspector void __fastcall TForm1::FormCreate(TObject *Sender) { Application->OnHint = DisplayHint; }
Delphi Examples:
{ This example uses an edit box and a list box on a form. Items are added to the list box and a Help Hint is assigned to both controls. The last statement enables the Help Hints for the entire application. } procedure TForm1.FormCreate(Sender: TObject); var I: Integer; begin Edit1.Hint := 'Enter your name'; Edit1.ShowHint := True; with ListBox1 do begin for I := 1 to 10 do Items.Add('Item ' + IntToStr(I)); Hint := 'Select an item'; ShowHint := True; end; Application.ShowHint := True; end; { Note: To see an example that displays the hints of controls in some place other than in a Help Hint box, see the OnHint example. }
{ Note: It is not actually necessary to write an OnHint event handler to display hints on the status bar. This can be accomplished more simply by setting the status bar’s AutoHint property and SimplePanel property. This shows how the OnHint event handler is declared as a public method of the form. } type TForm1 = class(TForm) Button1: TButton; StatusBar1: TStatusBar; Edit1: TEdit; procedure FormCreate(Sender: TObject); private { Private declarations } public procedure DisplayHint(Sender: TObject); end; var Form1: TForm1; implementation {$R *.dfm} { Here is the implementation of the OnHint event handler } { It displays the application’s current hint in the status bar } procedure TForm1.DisplayHint(Sender: TObject); begin StatusBar1.SimpleText := GetLongHint(Application.Hint); end; { Here is the form’s OnCreate event handler. } { It assign’s the application’s OnHint event handler at runtime } { because the Application is not available in the Object Inspector } { at design time } procedure TForm1.FormCreate(Sender: TObject); begin Application.OnHint := DisplayHint; end;
Copyright(C) 2008 CodeGear(TM). All Rights Reserved.
|
What do you think about this topic? Send feedback!
|