因為TMainMenu沒有ShowHint屬性,一般是顯示在StatusBar中
首先新增元件
TButton; 屬性Caption=Hint; 屬性Hint=提示!哈哈哈; 屬性ShowHint=True;
TMainMenu; (新增兩個按鈕喔N1及N2);
N1; 屬性Caption=檔案; 屬性Hint=檔案描述;
N2; 屬性Caption=開啟; 屬性Hint=開啟檔案;
TStatusBar;
事件:
TButton點兩下加入事件。
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Menus, ComCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
MainMenu1: TMainMenu;
N1: TMenuItem;
N2: TMenuItem;
StatusBar1: TStatusBar;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
procedure WhenHint(sender: TObject);
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
Application.HintPause := 100; //游標停留多久後顯示
Application.HintHidePause := 5000; //顯示多久
Application.HintShortPause := 5000; //若兩個元件有Hint(應該為重覆位置),設定其間隔顯示時間
Application.HintColor := clBlack; //hint背景色
Screen.HintFont.Color := clWindow; //hint字型顏色
//Screen.HintFont.Size := 12; //修改字型大小
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
Application.OnHint := WhenHint; //顯示Hint到StatusBar中
end;
procedure TForm1.WhenHint(sender: TObject);
begin
StatusBar1.SimpleText := Application.Hint;
end;
end.
沒有留言:
張貼留言