获取鼠标位置和控件区域

procedure TForm1.scSplitView1MouseEnter(Sender: TObject);
begin
if scSplitView1.Opened then
Exit;
scSplitView1.Opened := True;
Label1.Visible := True;
Label2.Visible := True;
end;

procedure TForm1.scSplitView1MouseLeave(Sender: TObject);
var
P: TPoint;
R: TRect;
begin
GetWindowRect(scSplitView1.Handle, R);
GetCursorPos(P);

if PtInRect(R, P) then
exit
else
begin
//这里要先隐藏文字,不然会看到字体向左移动
Label1.Visible := False;
Label2.Visible := False;
scSplitView1.Opened := False;
end;
end;

posted @ 2023-05-10 16:00  lucken  阅读(62)  评论(0)    收藏  举报