User forums > Help
GetStockObject not working right?
Knyght:
Not sure if thise is the right forum, or if I should be asking at all, but I don't know where else to ask, so here goes.
from wingdi.h, included by windows.h.
hFont = GetStockObject(SYSTEM_FONT);
This should work. msdn says the function should be HGDIOBJ GetStockObject(int fnObject); which looks right for what I'm doing.
I looked in wingdi.h and the function declaration is the same.
However, when I run it in codeblocks I get "error: invalid conversion from 'void*' to 'HFONT__*'. This seems odd.
Am I doing something wrong, or is it a problem elsewhere?
Thanks.
sethjackson:
This should work. :D
--- Code: (cpp) ---hFont = static_cast<HFONT>(GetStockObject(SYSTEM_FONT));
--- End code ---
thomas:
--- Code: ---typedef void *HGDIOBJ;
[...]
WINGDIAPI HGDIOBJ WINAPI GetStockObject(int);
[...]
HFONT hFont = GetStockObject(SYSTEM_FONT);
--- End code ---
No problem, that's perfectly right. The compiler says exactly what you do.
Try casting to HFONT as Seth said.
sethjackson:
BTW see here for why.
http://www.winprog.org/tutorial/errors.html#C2440
DO NOT cast the way they suggested. :P
static_cast, and it's friends are sooooo much better. :)
thomas:
--- Quote from: sethjackson on February 06, 2006, 09:37:42 pm ---DO NOT cast the way they suggested. :P
static_cast, and it's friends are sooooo much better. :)
--- End quote ---
Casting is a hack anyway, so why make such a fuzz about it :P
Navigation
[0] Message Index
[#] Next page
Go to full version