I
import
Unregistered / Unconfirmed
GUEST, unregistred user!
下面的代码,展示了如何在一个包含多个panel的状态栏中检测其中某个Panel受到鼠标双击。别忘了在单元的uses部分加上对CommCtrl的引用。
procedure TMainForm.StatusBar1DblClick(Sender: TObject);
var MouseCor : TPoint;
PanelRect: TRect;
lp0 : integer;
SB : TStatusBar;
begin
if Assigned(sender) then
begin
if Sender is TStatusBar then
begin
GetCursorPos(MouseCor);
SB := TStatusBar(Sender);
for lp0 := 0 to SB.Panels.Count-1 do
begin
SendMessage(SB.Handle, SB_GETRECT, lp0, Integer(@PanelRect));
if PtInRect(PanelRect,SB.ScreenToClient(MouseCor)) then begin
// 在这里添加处理代码
// SB.Panels[lp0]被点击
break;
end;
end;
end;
end;
end;
procedure TMainForm.StatusBar1DblClick(Sender: TObject);
var MouseCor : TPoint;
PanelRect: TRect;
lp0 : integer;
SB : TStatusBar;
begin
if Assigned(sender) then
begin
if Sender is TStatusBar then
begin
GetCursorPos(MouseCor);
SB := TStatusBar(Sender);
for lp0 := 0 to SB.Panels.Count-1 do
begin
SendMessage(SB.Handle, SB_GETRECT, lp0, Integer(@PanelRect));
if PtInRect(PanelRect,SB.ScreenToClient(MouseCor)) then begin
// 在这里添加处理代码
// SB.Panels[lp0]被点击
break;
end;
end;
end;
end;
end;