?
Solved

DoubleClick on a TStatusPanel

Posted on 2007-04-02
6
Medium Priority
?
489 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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 2000 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

777 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