//from Delphi Help
type
TForm1 = class(TForm)
Panel1: TPanel;
SpeedButton1: TSpeedButton;
SpeedButton2: TSpeedButton;
SpeedButton3: TSpeedButton;
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
procedure DoShowHint(var HintStr: string; var CanShow: Boolean;
var HintInfo: THintInfo);
end;
var
Form1: TForm1;
implementation{$R *.DFM}
procedure TForm1.DoShowHint(var HintStr: string; var CanShow: Boolean; var HintInfo: THintInfo);
begin
if HintInfo.HintControl = SpeedButton3 then
begin
with HintInfo do
begin
HintColor := clAqua;{ Changes only for this hint }
HintMaxWidth := 120;{Hint text word wraps if width is greater than 120 }
Inc(HintPos.X, SpeedButton3.Width); { Move hint to right edge } end;
end;
end;procedure TForm1.FormCreate(Sender: TObject);
begin
Application.ShowHint := True;
Application.OnShowHint := DoShowHint;
end;
end.
type
TForm1 = class(TForm)
Panel1: TPanel;
SpeedButton1: TSpeedButton;
SpeedButton2: TSpeedButton;
SpeedButton3: TSpeedButton;
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
procedure DoShowHint(var HintStr: string; var CanShow: Boolean;
var HintInfo: THintInfo);
end;
var
Form1: TForm1;
implementation{$R *.DFM}
procedure TForm1.DoShowHint(var HintStr: string; var CanShow: Boolean; var HintInfo: THintInfo);
begin
if HintInfo.HintControl = SpeedButton3 then
begin
with HintInfo do
begin
HintColor := clAqua;{ Changes only for this hint }
HintMaxWidth := 120;{Hint text word wraps if width is greater than 120 }
Inc(HintPos.X, SpeedButton3.Width); { Move hint to right edge } end;
end;
end;procedure TForm1.FormCreate(Sender: TObject);
begin
Application.ShowHint := True;
Application.OnShowHint := DoShowHint;
end;
end.
procedure TMainForm.FormCreate(Sender: TObject);
begin
Application.OnHint := ShowHint;
//....
end;//....
procedure TMainForm.ShowHint(Sender: TObject);
begin
if Length(Application.Hint) > 0 then
begin
StatusBar.SimplePanel := True;
StatusBar.SimpleText := Application.Hint;
end
else StatusBar.SimplePanel := False;
end;
//....
OnShowHint中捕捉
设置StatusBar1的AutoHint为True,就可以在控件上方显示 "我的",
在StatusBar1的Panels[0]中显示"这样".
只能在Panels[0]中显示。
Left = 0
Top = 329
Width = 536
Height = 19
AutoHint = True
Panels = <>
SimplePanel = True
end