Wednesday, February 24, 2021

Error E0513 a value of type "HGDIOBJ" cannot be assigned to an entity of type "HBRUSH"

Error E0513 a value of type "HGDIOBJ" cannot be assigned to an entity of type "HBRUSH"

  1. Color window in hbrBackground
  2. static_cast <HBRUSH > doesn't work as HBRUSH is defined as typedef HBRUSH__ *HBRUSH and so requires a reinterpret_cast

  3. Conversion from HGDIOBJ to HBRUSH
  4. (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);

  5. Window Programming
  6. a pdf book.

  7. Windows graphics device interface and Windows drawing
  8. Windows graphics device interface and Windows drawing

  9. This is a paragraph.

  10. This is a paragraph.

  11. This is a paragraph.

  12. This is a paragraph.

  13. This is a paragraph.

  14. This is a paragraph.

  15. This is a paragraph.

  16. This is a paragraph.

  17. This is a paragraph.

  18. This is a paragraph.

  19. This is a paragraph.

  20. This is a paragraph.

  21. This is a paragraph.

  22. This is a paragraph.

1 comment: