📄 mainwhat.pas
字号:
unit MainWhat;interfaceuses SysUtils, Types, Classes, QGraphics, QControls, QForms, QDialogs, Qt, QStdCtrls, QComCtrls, QMenus, QTypes;type TForm1 = class(TForm) Edit2: TEdit; Edit3: TEdit; Edit1: TEdit; ToolBar1: TToolBar; ToolButton1: TToolButton; PopupMenu1: TPopupMenu; WhatsThis1: TMenuItem; EnterWhatsthis1: TMenuItem; procedure FormCreate(Sender: TObject); procedure ToolButton1Click(Sender: TObject); procedure WhatsThis1Click(Sender: TObject); procedure PopupMenu1Popup(Sender: TObject); procedure EnterWhatsthis1Click(Sender: TObject); private { Private declarations } FCurrPoint : TPoint; FCompName : String; public { Public declarations } end;var Form1: TForm1;implementation{$R *.xfm}procedure TForm1.FormCreate(Sender: TObject);var i : Integer; WhatsText : WideString;begin// creates what's this text for each Edit for i := 1 to 3 do begin WhatsText := '<center><img src="'+ExtractFilePath(ParamStr(0))+'sattach.bmp"/>'+ '<h2>This is a What''s This help for <i>Edit'+IntToStr(i)+'</i></h2><br/>'+ 'This text should be shown in <b>bold</b></center>';// assigns the text to the component QWhatsThis_add((FindComponent('Edit'+IntToStr(i)) as TEdit).Handle,@WhatsText); end;end;procedure TForm1.ToolButton1Click(Sender: TObject);begin
QWhatsThis_enterWhatsThisMode;
end;
procedure TForm1.PopupMenu1Popup(Sender: TObject);
begin
// gets popup menu point
FCurrPoint := Mouse.CursorPos;
// gets the component name wher the menu was activated
if Sender is TPopupMenu then
FCompName := TPopupMenu(Sender).PopupComponent.Name;
end;
procedure TForm1.WhatsThis1Click(Sender: TObject);var
WhatsText : WideString;
begin
WhatsText := 'This is a What''s This help for <i>'+FCompName+'</i><p>'+
'It should be shown clicking the <b>Right button</b>'; QWhatsThis_enterWhatsThisMode;// exits whatsthis mode and shows the text QWhatsThis_leaveWhatsThisMode(@WhatsText,@FCurrPoint);end;
procedure TForm1.EnterWhatsthis1Click(Sender: TObject);begin
QWhatsThis_enterWhatsThisMode;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -