Solved

Mouse Events

Posted on 1998-04-12
10
330 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
 
LVL 1

Expert Comment

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

0
 
LVL 3

Author Comment

by:Matvey
Comment Utility
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
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 
LVL 5

Accepted Solution

by:
inter earned 60 total points
Comment Utility
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
Comment Utility
Hey, Thanks inter that's some slick code.
0
 
LVL 5

Expert Comment

by:inter
Comment Utility
You are wecome friend :-) Igor.
0
 
LVL 3

Author Comment

by:Matvey
Comment Utility
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
Comment Utility
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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

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 I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

763 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

10 Experts available now in Live!

Get 1:1 Help Now