If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register or Login
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

[RESOLVED] GDI Object Failing

I'm writing a program that will display bitmaps in its view. It is a view without a document. When the CBitmap does the LoadBitmap(nID) function, the CGDIObject does not initialize the CBitmap object and obtain the m_hObject value - it remains NULL. I have used the exact same code elsewhere, and it works fine, can anyone tell me how it may work in one place, and not another?

Re: GDI Object Failing

Originally Posted by He_That_Is

... When the CBitmap does the LoadBitmap(nID) function, the CGDIObject does not initialize the CBitmap object and obtain the m_hObject value - it remains NULL.

Did you check the return value of LoadBitmap? Isn't it zero (FALSE)?
Does your resource file contain these bitmaps?
Are the resource IDs in the resource file the same as you use in your CChildView class?

Re: GDI Object Failing

The return from the LoadBitmap() is FALSE (0), should be returning TRUE (1). The resource,h contains all of the resource ID's they are all correct and accurate, and the same as I am using in CChildView. The indices are correct, and work fine in another project. This really has ma stumped.

Re: GDI Object Failing

I took a closer to the resource info, and found a very interesting dilema. resource has the exact same resource ID's with the correct values, however, when I open the Resource ID editor (right-click on .rc file and select "Resource ID") the data names are exactly the same, but all of the values are different. I have never seen anything like this before. I have corrected the value discrepancies, and now it works fine. Thank you for mentioning the resources as this drew me in to look closer.

Re: GDI Object Failing

Originally Posted by He_That_Is

I took a closer to the resource info, and found a very interesting dilema. resource has the exact same resource ID's with the correct values, however, when I open the Resource ID editor (right-click on .rc file and select "Resource ID") the data names are exactly the same, but all of the values are different. I have never seen anything like this before. I have corrected the value discrepancies, and now it works fine. Thank you for mentioning the resources as this drew me in to look closer.

You still didn't answer Philip.

Those indices are not correct. You have a buffer overrun. Whether they "work" in another project doesn't matter. When you overrun the array buffer, anything can happen, including "working", crashing, working today and not tomorrow, etc.