5,388
社区成员
发帖
与我相关
我的任务
分享
procedure TForm1.StatusBar1DblClick(Sender: TObject);
var
i, nLeftOffset: integer;
r: TRect;
pt: TPoint;
begin
nLeftOffset := 0;
pt := StatusBar1.ScreenToClient(Mouse.CursorPos);
with StatusBar1 do
begin
for i := 0 to Panels.Count - 1 do
begin
r.Left := nLeftOffset;
r.Top := 0;
r.Bottom := Height;
if i < Panels.Count - 1 then
r.Right := r.Left + Panels.Items[i].Width
else
r.Right := Width;
nLeftOffset := nLeftOffset + Panels.Items[i].Width;
if PtInRect(r, pt) then
begin
ShowMessage(Format('鼠标在第%d个Panel双击了', [i + 1]));
Exit;
end;
end;
end;
end;