Solved

Mouse Events

Posted on 1998-04-12
10
340 Views
Last Modified: 2008-02-01
How do I know when the mouse button is release, while ControlStyle doesn't contains csCaptureMouse?

That means that a user can release the mouse button over other control than the clicked one and the event goes to the other control. How can I make the "clicked" control to still "know" that the button was released, even if the button wasn't released while pointre still on itself?

If to go farther: I need that to achive buttons that act like in WinAmp (www.winamp.com)

Big thanks!

Matvey (bosism@netvision.net.il)
0
Comment
Question by:Matvey
[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
  • 4
  • 2
  • 2
  • +2
10 Comments
 
LVL 1

Expert Comment

by:pjdb
ID: 1361427
I'm not sure to understand the question....
Do you want to consider a click on the control even if the release action occur while the pointer is not on the control? If so can you explain how a user will do to cancel his mousedown if he has make a mistake?
Usually there is a mouse leaving to unpress the button (called when the mouse pointer is leaving the control area or by mouseup) and an action (called when the mouseup)

The first one can be managed by the mousemove event and the second one by the mouseup event

JDB
0
 
LVL 3

Author Comment

by:Matvey
ID: 1361428
It's not about considering every event as aclick. You see, if you have in ControlStyle the csCaptureMouse flag - you get the  MouseUp event anyway, otherwise the other controls get this event depanding where the button was released. What I want is for the clicked object to get this event somehow too, and handle it somehow.

Is it clearer now? :-)
0
 
LVL 8

Expert Comment

by:ZifNab
ID: 1361429
Hi Matvey,

Can you explain to us what you what to achieve? With an example?
Why don't you use button which stay in the down face when you click on them?

ZiF.
0
Independent Software Vendors: 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 1

Expert Comment

by:Greedy
ID: 1361430
Are you like trying to do a drag and drop interface or somthing...

0
 
LVL 3

Author Comment

by:Matvey
ID: 1361431
Heyo there,

If you want to know what I want to do then download a very small player at www.winamp.com

I want to make button components like that player has...
0
 
LVL 5

Accepted Solution

by:
inter earned 60 total points
ID: 1361432
Hi there,

Here it is (sorry I have not much time to share, you may drive  a control for yourself by overriding MouseMove event anchestor. Also  this works with csMouseCapture)

Here is the source fragment for the task without component overriding

var
  Down : boolean = false;

procedure XMouse(Sender: TObject; Shift: TShiftState; X, Y: Integer);
begin
    if (ssLeft in Shift) and not Down then
  begin
    (Sender as TButton).Perform(WM_LBUTTONDOWN, 0, Longint(PointToSmallPoint(Point(X,Y))));
    Down := true;
  end else if not PtInRect((Sender as TButton).ClientRect, Point(X,Y)) then
  begin
    SetCaptureControl(nil);
    Down := false;
  end;
end;

procedure TForm1.Button3MouseMove(Sender: TObject; Shift: TShiftState; X,
  Y: Integer);
begin
  XMouse(Sender, Shift, X,Y);
end;

procedure TForm1.Button4MouseMove(Sender: TObject; Shift: TShiftState; X,
  Y: Integer);
begin
  XMouse(Sender, Shift, X,Y);
end;


So just add the XMouse clause to the control you want to behave like that
Regards,
Igor
0
 
LVL 1

Expert Comment

by:Greedy
ID: 1361433
Hey, Thanks inter that's some slick code.
0
 
LVL 5

Expert Comment

by:inter
ID: 1361434
You are wecome friend :-) Igor.
0
 
LVL 3

Author Comment

by:Matvey
ID: 1361435
Whooow! Igor that is a great pice of code!

Big true thatnks!!!

PS Igor, I've been trying to reach you through email, but I receive all the messages back.

inter@kosgeb.tekmer.gov.tr

Is this supose to work? -Maybe you have other email?

Whatever - big big thanks again - I've already lost hope and was waitiing for this question to be deleeted!

(PS double points...)
0
 
LVL 3

Author Comment

by:Matvey
ID: 1361436
Inter, I was wondering if this could be done with components from TGraphicControl, and is there a part that csCaptureMouse can play in it?

Also can we do it somehow the way so clicking on the form itsef will produce the same result? I meanlike if the user clicks and holds the mouse button while moving to buttons...

PS received a message from you and replied - hope you receive it this time :)
0

Featured Post

Enroll in May's Course of the Month

May’s Course of the Month is now available! Experts Exchange’s Premium Members and Team Accounts have access to a complimentary course each month as part of their membership—an extra way to increase training and boost professional development.

Question has a verified solution.

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

Suggested Solutions

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…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

751 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