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..
anyway i think i did it..
Code:
int i;
int j;
int n;
CDC dc;
CPoint pt;
CRect rect;
CString txt;
BITMAP bitmap;
GetIconInfo((HICON)GetCursor(), &m_ii);
GetObject(m_ii.hbmMask, sizeof(BITMAP), &bitmap);
dc.CreateCompatibleDC(GetDC());
dc.SelectObject(m_ii.hbmMask);
n = 0;
for(i = 0; i < 32/*bitmap.bmWidth*/; i++)
{
for(j = 0; j < 32/*bitmap.bmHeight*/; j++)
{
if(dc.GetPixel(i, j) != RGB(255, 255, 255))
{
if(n < j)
{
n = j;
}
}
}
}
dc.DeleteDC();
GetCursorPos(&pt);
txt.Format("%d", pt.y + (n - m_ii.yHotspot) + 1);
MessageBox("This is where i need to place my ToolTip window: " + txt);
// GetWindowRect(&rect);
// MoveWindow(pt.x, pt.y + (n - m_ii.yHotspot) + 1, rect.Width(), rect.Height());
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
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