Solved

Mouse Events

Posted on 1998-04-12
10
335 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
  • 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
Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

 
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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

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…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

776 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