How do I fix the following errors?

CDev-8220 220 Reputation points
2024-04-02T16:31:23.0266667+00:00

I'm using the example code here, but getting errors in this area.

for (i = 0; i < CPENS; i++) {

phbmp[i] = CreateCompatibleBitmap(

hdcMain, wLineX, wLineY);

if (i == 0) {

hbmpOld = SelectObject(hdcLines, phbmp[i]);

}

else {

SelectObject(hdcLines, phbmp[i]);

}

ExtFloodFill(

hdcLines, 0, 0, crMenuClr, FLOODFILLBORDER);

}

Code:

phbmp[i] = CreateCompatibleBitmap(hdcMain, wLineX, wLineY);

Error:

no operator "=" matches these operands operand types are HBITMAP__=HBITMAP

Code:

hbmpOld = SelectObject(hdcLines, phbmp[i]);

Error:

a value of type "HGDIOBJ" cannot be assigned to an entity of type "HBITMAP" no suitable conversion function from "HBITMAP__" to "HGDIOBJ" exists

C++
C++
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
3,553 questions
{count} votes

Accepted answer
  1. Viorel 112.9K Reputation points
    2024-04-02T18:29:18.6033333+00:00

    Probably some characters were lost. To fix the first error, try to add “[ ]” to these parameters: HPEN phpen[], HBITMAP phbmp[].

    To fix the conversion problems, try to use HGDIOBJ instead of HBRUSH and HBITMAP for corresponding local variables, for example: HGDIOBJ hbmpOld.

    Maybe you can use the Feedback button to report the found documentation errors.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful