I'm trying to learn how to do some simple things with MFC - I'm not used to the toolkit. I want to load a png image from disk and display it at a chosen location in the program's window, but am getting a debug assertion error: atlimage.h
Line: 1624

Expression: hBitmap == m_hBitmap

The only initialization is:
CImage genericImage;
genericImage.Load(fName);

(it returns normally, with no errors)

Inside the WM_PAINT routine, the code is a simple:

genericImage.Draw( hdc, 0, 0);

Any ideas? It fails to paint anything if I ignore the debug error, and I can't find any suggestions in the documentation or example code, but I admit I find Microsoft's documentation pretty impenetrable.

Your code paste failed. However I'd look at prior examples found with:
https://duckduckgo.com/?q=cimage+c%2B%2B+example

commented: Thanks to composing the question to post here, I found a solution: rewrote it by changing the type of genericImage to cImage pointer, and it worked. +3
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.