Link to home
Start Free TrialLog in
Avatar of wqclatre
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
Avatar of mokule
mokule
Flag of Poland image

Maybe try like this

var
    xm,ym: integer;


procedure TForm1.StatusBar1MouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
  xm := X;
  ym := Y;
end;

procedure TForm1.StatusBar1DblClick(Sender: TObject);
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) then
      begin
      ShowMessage(IntToStr(i));
      exit;
      end;
    dx := dx + StatusBar1.Panels[i].Width;
    end;
  ShowMessage('No panel clicked');
end;
Avatar of wqclatre
wqclatre

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 ?
It's up to You how You declare xm, ym.
They can be private members in the Form's class.
Have you tryed this:

Statusbar2.ClientOrigin.X
Statusbar2.ClientOrigin.Y


Regards
Feels "global" to me.....  (global within the unit)
ASKER CERTIFIED SOLUTION
Avatar of TheRealLoki
TheRealLoki
Flag of New Zealand image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial