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 » U++ Library support » Draw, Display, Images, Bitmaps, Icons » image of cursor
icon5.gif  image of cursor [message #3642] Sat, 10 June 2006 10:41 Go to next message
andrei-catalin is currently offline  andrei-catalin
Messages: 62
Registered: May 2006
Location: Romania
Member
I'd like to change the image of cursor when the mouse is over a distinct control (a Picture, in my case).
What would be a way to make this?
Re: image of cursor [message #3644 is a reply to message #3642] Sat, 10 June 2006 12:12 Go to previous messageGo to next message
fudadmin is currently offline  fudadmin
Messages: 1298
Registered: November 2005
Location: London, UK
Senior Contributor
Administrator
Something like this:
Image MyCtrl::CursorImage(Point p, dword keyflags)
{
	Point p1=Point(0,50);
	Point p2=Point(200,60);
///	if (p.x>p1.x && p.x<p2.x && p.y>p1.y && p.y<p2.y)
///	return CtrlImg::vertpos1();
//		SetMouseCursor(CtrlImg::vertpos1());
	//	PromptOK("inside");

///	else return Image::Arrow();
	return Image::Arrow();
}
Re: image of cursor [message #3646 is a reply to message #3644] Sat, 10 June 2006 14:33 Go to previous messageGo to next message
andrei-catalin is currently offline  andrei-catalin
Messages: 62
Registered: May 2006
Location: Romania
Member
The code goes well. Smile

Thank you very much!

Andrei
Re: image of cursor [message #3649 is a reply to message #3644] Sun, 11 June 2006 20:53 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 12105
Registered: November 2005
Ultimate Member
fudadmin wrote on Sat, 10 June 2006 06:12

Something like this:
Image MyCtrl::CursorImage(Point p, dword keyflags)
{
	Point p1=Point(0,50);
	Point p2=Point(200,60);
///	if (p.x>p1.x && p.x<p2.x && p.y>p1.y && p.y<p2.y)
///	return CtrlImg::vertpos1();
//		SetMouseCursor(CtrlImg::vertpos1());
	//	PromptOK("inside");

///	else return Image::Arrow();
	return Image::Arrow();
}




Well, with those commented out lines, not quite a representative example... Wink

To original poster: Just return the Image you want from the CursorImage overload..

Mirek
Re: image of cursor [message #6123 is a reply to message #3649] Tue, 31 October 2006 16:34 Go to previous messageGo to next message
James Thomas is currently offline  James Thomas
Messages: 26
Registered: June 2006
Promising Member
I'm also having a problem with setting my cursor image and I thought I'd post here to save a thread.

I have overriden Ctrl::CursorImage to return my own custom image (loaded from a .GIF) and it replaces the cursor. The problem is that it doesn't get drawn at the position of the cursor but some distance below it. It appears to me as if it is drawn at the bottom of where the default Image::Arrow() cursor is normally drawn.

Any ideas to fix this?

Note: fudadmin's code above no longer works (I assume it did when he posted it) as Ctrl::SetMouseCursor is now a private member of Ctrl and cannot be called directly.
Re: image of cursor [message #6124 is a reply to message #6123] Tue, 31 October 2006 17:09 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 12105
Registered: November 2005
Ultimate Member
Looks like some hotspot problem.

Hotspot is a reference point in Image which defines the "mouse posisition". For regular arrow, it is [0, 0], but can be generally any point in the image.

Default value is [0, 0]. You can define hotspot position in Image designer (actually, dev versions of u++ have TWO hotspots now, HotSpot and "2ndSpot", but second hotspot is no used here Wink

Mirek
Re: image of cursor [message #6168 is a reply to message #6124] Wed, 01 November 2006 13:07 Go to previous message
James Thomas is currently offline  James Thomas
Messages: 26
Registered: June 2006
Promising Member
Thanks, that was the problem. For some reason all my Images have been loaded with hotspots at (0,-cy), but I have no idea why.

I think I missed this because the Image class doesn't have a SetHotSpot member (presumably because it's held in ImageBuffer and data->buffer could be NULL), and the only way I can find of setting a new hotspot is:

ImageBuffer ib;
Image img;

// Load an image here

ib = img;
ib.SetHotSpot(Point(0,0));
img = ib;

As far as I can tell this won't actually do any deep copying, but is it really the best way?
Previous Topic: Graphics Context and Draw Object
Next Topic: StreamRaster::LoadAnyFile -- not exist in distribution?
Goto Forum:
  


Current Time: Wed Nov 20 15:46:08 CET 2019

Total time taken to generate the page: 0.02679 seconds