Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » Community » Newbie corner » Drag of mouse while left button is pressed.
Drag of mouse while left button is pressed. [message #27625] Mon, 26 July 2010 18:23 Go to next message
281264 is currently offline  281264
Messages: 270
Registered: June 2010
Location: Spain
Experienced Member
Hi,

Which Ctrl function is invoked when and during the left button of the mouse is pressed? I have had a look on LeftDrag and LeftHold; are one of these suitable for what I want?

Cheers,

Javier
Re: Drag of mouse while left button is pressed. [message #27628 is a reply to message #27625] Mon, 26 July 2010 23:10 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3356
Registered: August 2008
Senior Veteran
281264 wrote on Mon, 26 July 2010 18:23

Hi,

Which Ctrl function is invoked when and during the left button of the mouse is pressed? I have had a look on LeftDrag and LeftHold; are one of these suitable for what I want?

Cheers,

Javier


Hello Javier

I use these functions instead:
	virtual void  LeftDown(Point, dword);
	virtual void  LeftUp(Point, dword);
	virtual void  MouseMove(Point, dword);
	virtual void  MouseLeave(Point, dword);


in a class derived of a Ctrl.


Best regards
Iñaki
Re: Drag of mouse while left button is pressed. [message #27639 is a reply to message #27628] Tue, 27 July 2010 12:11 Go to previous message
mrjt is currently offline  mrjt
Messages: 705
Registered: March 2007
Location: London
Contributor
The code you want is something like:
void LeftDown(Point p, dword keyflags)
{
   SetCapture(); 
   // All mouse events are now directed to this ctrl until ReleaseCapture is called
}

void MouseMovePoint p, dword keyflags)
{
   if (HasCapture())
      // Left mouse is depressed
   else
      // No button pressed
}

void LeftDown(Point p, dword keyflags)
{
   ReleaseCapture(); 
}

There are loads of other ways of doing it, but this is the cleanest for simple behaviour. You can also use LeftHold/LeftDrag but they have a slight delay before being triggered.
Previous Topic: How to compare child in function virtual void ChildMouseEvent with ctrl’s value.
Next Topic: How to adjust the height of an InfoCtrl frame’s height.
Goto Forum:
  


Current Time: Fri Apr 19 09:33:32 CEST 2024

Total time taken to generate the page: 0.02473 seconds