in the sdk documentation for the CreateCaret function a possible value for
the hBitmap parameter is given as (HBITMAP) 1
from an example CreateCaret(hwndMain, (HBITMAP) 1, 0, dwCharY);
I can't use something like (HBITMAP) 1 in the invoke call .
I used something like invoke CreateCaret, hWnd, NULL,1,16
and it seems to work proper,.. all the same I'd like to know what that (HBITMAP) 1 thing, is exactly.
ty
~~
From msdn:
QuoteHandle to the bitmap that defines the caret shape. If this parameter is NULL, the caret is solid. If this parameter is (HBITMAP) 1, the caret is gray. If this parameter is a bitmap handle, the caret is the specified bitmap. The bitmap handle must have been created by the CreateBitmap, CreateDIBitmap, or LoadBitmap function.
If hBitmap is a bitmap handle, CreateCaret ignores the nWidth and nHeight parameters; the bitmap defines its own width and height.
So: 0 (or null) means a solid rectangle (width and height given as parameters), 1 means a gray rectangle (of given width and height), and any other values are assumed to be a valid bitmap handle (with width and height ignored.)
Ted,
why did they include the '(HBITMAP)' part in their example in the function call.. why not just use 1 or NULL ? is what i meant.
& in Masm with invoke i can't use something like '(HBITMAP) 1'
thankyou.
CreateCaret(hwndMain, (HBITMAP) 1, 0, dwCharY);
The concept is called typecasting.
If not done a compiler will usually throw an error or a warning that the "second parameter is not of type HBITMAP" or something equivalent!!!
Not used that particular function, but the second parameter looks like that can be a "handle to bitmap", with specific meaning if it is 0, 1, etc, right ?
MASM (and most assemblers) will work with previously defined signature of a function (called "function prototype")
"CreateCaret" would have this second parameter defined as DWORD (instead of HBITMAP) and NULL is actually the numeric value 0 (zero), which is a valid DWORD, so no error!!! :bg :bg
HTH,
Shantanu
thanks for the info
the other parameters usually don't seem to have that typecasting.. when implementing the call though.
yes its a handle.. where NULL or 1 have special meanings.. besides using a handle to an actual bitmap itself
Quotethe other parameters usually don't seem to have that typecasting.. when implementing the call though.
The warning/error is actually at compilation side and not implementation! :bg
The function really doesn't care what you send as the second parameter.
Its the compiler that is enforcing us to do the typecast ... just to be sure you know what you are sending.
Regards,
Shantanu
yah I got that.. what I meant is like the examples for the other functions in the sdk don't usualy seem to have that when using the call like in the createCaret function too.
CreateCaret(hwndMain, (HBITMAP) 1, 0, dwCharY);
like the 3rd parameter there is of the type 'int' but in the call they just use '0' not 'int 0'.
as you see i don't know anthing about C.. just kinda get on the whole what the examples in
the sdk mean.
ty
~~