wqclatre
asked on
DoubleClick on a TStatusPanel
I need to have a OnDubleClick event on a TStatusPanel
(IE inside a statusBar OnDoubleClick I need to know which of the StatusPanels the double click is on
(IE inside a statusBar OnDoubleClick I need to know which of the StatusPanels the double click is on
ASKER
I don't like the idea of Global variables.
Isn't there a way to get the ScreenPositions for the StatusPanel[2] for example ?
Isn't there a way to get the ScreenPositions for the StatusPanel[2] for example ?
It's up to You how You declare xm, ym.
They can be private members in the Form's class.
They can be private members in the Form's class.
Have you tryed this:
Statusbar2.ClientOrigin.X
Statusbar2.ClientOrigin.Y
Regards
Statusbar2.ClientOrigin.X
Statusbar2.ClientOrigin.Y
Regards
ASKER
Feels "global" to me..... (global within the unit)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
var
xm,ym: integer;
procedure TForm1.StatusBar1MouseDown
Shift: TShiftState; X, Y: Integer);
begin
xm := X;
ym := Y;
end;
procedure TForm1.StatusBar1DblClick(
var
i: integer;
dx: integer;
begin
dx := 0;
for i := 0 to StatusBar1.Panels.Count - 1 do
begin
if (xm > dx) and (xm < dx+ StatusBar1.Panels[i].Width
begin
ShowMessage(IntToStr(i));
exit;
end;
dx := dx + StatusBar1.Panels[i].Width
end;
ShowMessage('No panel clicked');
end;