hey does anybody know how to get the visible part (not the transparent background) of the current used mouse cursor? i know they are all 32x32 and im trying to make my own ToolTip control and place it exactly under the visible mouse cursor..

what i get on the MessageBox is right until i set the cursor as "Use Default" in Control Panel - Mouse - Pointers (Windows XP)..

it gets invalid (a weird large number) bitmap.bmWidth and bitmap.bmHeight and i also tried painting the cursor and it will just paint a black square when i do that.. other than that it works and paints the cursor too with a black background

also i hope im not mistaking that i think the black color is the transparent color for all mouse cursors right?

thanks

09-02-2008

master5001

If I am not mistaken, that is a possible return for GetSystemMetrics(). But I am too lazy to msdn it and I am not using my computer thus I don't have msdn on this machine.

09-02-2008

eXistenZ

that will just get me the whole rectangular size of the cursor and im only interested in the visible part of it and not the transparent part too

thanks anyway

09-03-2008

novacain

Quote:

Originally Posted by eXistenZ

hey does anybody know how to get the visible part (not the transparent background) of the current used mouse cursor? i know they are all 32x32 and im trying to make my own ToolTip control and place it exactly under the visible mouse cursor..

im using MFC in Visual C++ 6.0

thanks

You could manually calculate an offset based on the standard mouse icons and OS version (ie screen capture the mouse and measure the transparent part image(s) in a paint program, offset the tooltip based on OS and type of cursor).

Ummmm.....but this sounds like a lot of work just for a few pixcels diff, for a tooltip placement (is this level of accuracy required, given the work invloved?).

09-03-2008

matsp

Quote:

Originally Posted by eXistenZ

that will just get me the whole rectangular size of the cursor and im only interested in the visible part of it and not the transparent part too

thanks anyway

But that is all that Windows knows - it doesn't actually know what part of each cursor is being used or is transparent. That is up to the driver to sort out. There is a "hotspot" for the cursor, which indicates which point of the cursor is the "actual point", but that may be an arbitrary point in relation to what is drawn as the cursor.

So, in summary, all cursors, to the general parts of windows, are rectangles [or squares - can't quite remember if the cursor is actually allowed to be non-square, I seem to only remember having worked [1] with square ones]. Only the bits of code in the display driver that draws the actual cursor knows what part of the cursor is actually showing up on the screen or not.

Edit: So the only workable solution is to read the cursor image data, and determine from that what parts of the cursor are visible. That's messy, I can tell you [I had to do it "by hand" at times for debugging purposes, and it's no fun at all]. Bear in mind also that cursors come in several formats, so you need to cope with 1 bit per pixel with a mask layer as well as 32 bpp using alpha.

[1] A few years ago, I ported the cursor (= mouse pointer) drawing functions in a Windows driver from one model of graphics chip to another one.

--
Mats

09-03-2008

eXistenZ

Quote:

Originally Posted by matsp

But that is all that Windows knows - it doesn't actually know what part of each cursor is being used or is transparent. That is up to the driver to sort out. There is a "hotspot" for the cursor, which indicates which point of the cursor is the "actual point", but that may be an arbitrary point in relation to what is drawn as the cursor.

So, in summary, all cursors, to the general parts of windows, are rectangles [or squares - can't quite remember if the cursor is actually allowed to be non-square, I seem to only remember having worked [1] with square ones]. Only the bits of code in the display driver that draws the actual cursor knows what part of the cursor is actually showing up on the screen or not.

Edit: So the only workable solution is to read the cursor image data, and determine from that what parts of the cursor are visible. That's messy, I can tell you [I had to do it "by hand" at times for debugging purposes, and it's no fun at all]. Bear in mind also that cursors come in several formats, so you need to cope with 1 bit per pixel with a mask layer as well as 32 bpp using alpha.

[1] A few years ago, I ported the cursor (= mouse pointer) drawing functions in a Windows driver from one model of graphics chip to another one.

--
Mats

all i want to do is make my own made ToolTip window work exactly like the standard windows one..

THE ONLY PROBLEM is that whenever i use a black and white cursor bitmap.bmWidth and bitmap.bmWidth get invalid values.. thats my only problem (i think, please tell me if there are more) so if you know how to make it get the right width and height on a black and white cursor please tell me

Quote:

Originally Posted by novacain

is this level of accuracy required, given the work invloved?

yes it is.. why start making something if you don't want to make it good or finish it?

this is how i think.. i always try to finish everything i start..

thanks

09-03-2008

matsp

Are you sure that you can't use the ICONINFO xHotSpot and yHotSpot instead?

As to black and white cursor, it is mentionened here:

Quote:

Originally Posted by MSDN about ICONINFO

Specifies the icon bitmask bitmap. If this structure defines a black and white icon, this bitmask is formatted so that the upper half is the icon AND bitmask and the lower half is the icon XOR bitmask. Under this condition, the height should be an even multiple of two. If this structure defines a color icon, this mask only defines the AND bitmask of the icon.

--
Mats

09-03-2008

eXistenZ

Quote:

Originally Posted by matsp

Are you sure that you can't use the ICONINFO xHotSpot and yHotSpot instead?

As to black and white cursor, it is mentionened here:

--
Mats

i tested a lot of cursors and it seems to work exactly right..

oh and stupid me for not reading the msdn documentation carefully.. :D sorry

yes it is.. why start making something if you don't want to make it good or finish it?

this is how i think.. i always try to finish everything i start..

A comendable attitude, but...

Depends on the apps requirements and what are the vital features and which are 'polish'.

Got a bug that interfers with core functionality but only very occasionally? spend hours/days fixing it.

I would not be happy if a member of my team spent even an hour ensuring the tooltip appears 2-3 pix more accurately, I have much more important things for them to do (and never enough time to do them).

09-05-2008

eXistenZ

Quote:

Originally Posted by novacain

A comendable attitude, but...

Depends on the apps requirements and what are the vital features and which are 'polish'.

Got a bug that interfers with core functionality but only very occasionally? spend hours/days fixing it.

I would not be happy if a member of my team spent even an hour ensuring the tooltip appears 2-3 pix more accurately, I have much more important things for them to do (and never enough time to do them).

thats the difference between making something for money and making something for free and what im making it is for free :P

09-05-2008

novacain

Quote:

Originally Posted by eXistenZ

thats the difference between making something for money and making something for free and what im making it is for free :P

No. It is a fundamental principle of software engineering, one that took me years of cutting coding to appreciate.