让菜单提示消失的代码加在哪里呢?
本帖最后由 冥界3大法王 于 2021-4-18 20:01 编辑Application.ShowHint := False;
{ Private declarations }
public
HintWindow: THintWindow;
procedure DisplayHint(Sender: TObject);
{ Public declarations }
end;
var
Form1: TForm1;
ID: Integer;
id_A1: Integer;//为Ctrl+下箭头定义一个变量
p: TPoint; //在光标处弹出我们的菜单来
uses
ActnList, Clipbrd, ShellAPI;
procedure TForm1.DisplayHint(Sender: TObject);
var
point1: TPoint;
width: integer;
size1: size;
hintstr: string;
begin
hintstr := GetLongHint(application.Hint);
if hintstr <> '' then
begin
//计算宽度;
GetTextExtentPoint32(getdc(form1.Handle), pchar(hintstr), length(hintstr) + 6, size1);
getcursorpos(point1);
//得到位置;
HintWindow.ActivateHint(Rect(point1.x, point1.y, point1.X + size1.cx, point1.y + size1.cy + 6), hintstr);
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
Application.ShowHint := true;
Application.OnHint := DisplayHint;
HintWindow := THintWindow.Create(self);
end;
procedure TForm1.FormMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
begin
if Assigned(HintWindow) then
HintWindow.ReleaseHandle;
end;
页:
[1]