Doing HFONT childfont = SendMessage (childwin, WM_GETFONT, NULL, NULL); results in the error “invalid conversion from ‘LRESULT’ to ‘HFONT__*'” when MSDN states that the return type is HFONT. What is the proper return type for this function? Should I just use LRESULT or is there something special I have to do because my program will come back and bite me later if I don’t do it?
Doing HFONT childfont = SendMessage (childwin, WM_GETFONT, NULL, NULL); results in the error invalid
Share
SendMessageis a Swiss army knife: it does a lot of different things, all of which return various types of values. Since C does not support overloaded return values (remember that the Win32 API is a C API), it has to return a genericLRESULTtype.So, you need to cast the result to the actual type. The documentation states that it this message returns an
HFONT, so you must cast the result to anHFONT:Alternatively, you can use the macro
GetWindowFont()defined in the header file<WindowsX.h>, which includes a lot of utility macros: