Error E0513 a value of type "HGDIOBJ" cannot be assigned to an entity of type "HBRUSH"
- Color window in hbrBackground
- Conversion from HGDIOBJ to HBRUSH
- Window Programming
- Windows graphics device interface and Windows drawing
static_cast <HBRUSH > doesn't work as HBRUSH is defined as typedef HBRUSH__ *HBRUSH and so requires a reinterpret_cast
(This question is asked in the context of Win32API using the g++ compiler). I have a trouble with understanding why the following line of code won't work
wndclass.hbrBackground = GetStockObject(WHITE_BRUSH);
wndclass is an instance of the WNDCLASSEX structure, and the Windows API clearly specifies that the type of its member hbrBackground is HBRUSH. Further, HBRUSH is just a typedef for a HANDLE, which in turn is a typedef for void*. Hence, HBRUSH should be of type void*. Now, the GetStockObject function's return type is HGDIOBJ, which is also typedefed as a HANDLE, hence a void*.
A Solution: pBrush = static_cast < HBrushGDI* >GetStockObject(WHITE_BRUSH);
a pdf book.
Windows graphics device interface and Windows drawing
This is a paragraph.
This is a paragraph.
This is a paragraph.
This is a paragraph.
This is a paragraph.
This is a paragraph.
This is a paragraph.
This is a paragraph.
This is a paragraph.
This is a paragraph.
This is a paragraph.
This is a paragraph.
This is a paragraph.
This is a paragraph.
Thank you for your help!
ReplyDelete