Solved

Mouse Events

Posted on 1998-04-12
10
333 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
 
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

943 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

5 Experts available now in Live!

Get 1:1 Help Now