Solved

Mouse Events

Posted on 1998-04-12
10
342 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

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…
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…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Suggested Courses
Course of the Month8 days, 19 hours left to enroll

617 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