Solved

DoubleClick on a TStatusPanel

Posted on 2007-04-02
6
472 Views
Last Modified: 2012-08-13
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
0
Comment
Question by:wqclatre
6 Comments
 
LVL 17

Expert Comment

by:mokule
ID: 18835534
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;
0
 
LVL 2

Author Comment

by:wqclatre
ID: 18835706
I don't like the idea of Global variables.

Isn't there a way to get the ScreenPositions for the StatusPanel[2] for example ?
0
 
LVL 17

Expert Comment

by:mokule
ID: 18835776
It's up to You how You declare xm, ym.
They can be private members in the Form's class.
0
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 11

Expert Comment

by:calinutz
ID: 18835781
Have you tryed this:

Statusbar2.ClientOrigin.X
Statusbar2.ClientOrigin.Y


Regards
0
 
LVL 2

Author Comment

by:wqclatre
ID: 18835787
Feels "global" to me.....  (global within the unit)
0
 
LVL 17

Accepted Solution

by:
TheRealLoki earned 500 total points
ID: 18920521
This is all you need, and is not global

procedure TForm1.StatusBar1DblClick(Sender: TObject);
var
  WhichPanel, wdth: integer;
  cp: tpoint;
begin
  cp := mouse.CursorPos;
  cp.x := cp.x - (sender as TStatusBar).ClientOrigin.x;
  WhichPanel := 0;
  wdth := 0;
  while (WhichPanel < (sender as TStatusBar).Panels.Count) and
        (cp.x > wdth + (sender as TStatusBar).Panels[WhichPanel].Width) do
  begin
    wdth := wdth + (sender as TStatusBar).Panels[WhichPanel].Width;
    inc(WhichPanel);
  end;
  ShowMessage('You clicked on panel # ' + Inttostr(WhichPanel));
end;
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now