在您的表单中添加一个名为 Timer1 的 TTimer 控件(可能来自系统选项卡控件)。
将 Timer1 Inteval 属性设置为 100,这意味着它将每 100 毫秒检查一次光标位置(每秒 10 次)。
将 Timer1 Enabled 属性设置为 True。
将以下代码添加到 Timer1 的 OnTimer 事件中:
procedure TForm1.Timer1Timer(Sender: TObject);
var
oCursorPos: TPoint;
oImagePos: TPoint;
bInside: boolean;
begin
//Get position of Cursor in Screen Coordinates
GetCursorPos(oCursorPos);
//Convert coordinates of Image1 from Client to Screen Coordinates
oImagePos := Self.ClientToScreen(Point(Image1.Left, Image1.Top));
bInside := (oCursorPos.x >= oImagePos.x) and (oCursorPos.x <= oImagePos.x + Image1.Width) and
(oCursorPos.y >= oImagePos.y) and (oCursorPos.y <= oImagePos.y + Image1.Height);
if bInside then
begin
//Cursor is over Image1 -> insert code to show the secondary form
end
else
begin
//Cursor is not over Image1 -> insert code to hide the secondary form
end;
end;
Copyright © 2014 DelphiW.com 开发 源码 文档 技巧 All Rights Reserved
晋ICP备14006235号-8 晋公网安备 14108102000087号
执行时间: 0.052090167999268 seconds