Solved – CDHtmlDialog and bitmap resources

Today I am working on some old code and am being frustrated by the CDHtmlDialog class in MFC7. All I want to do is display some hyperlinks and a BMP image embedded in the EXE as a resource – is that so very hard? Well it can be done but it’s not well documented. Here is my solution which I worked out from hours of reading MSDN, forums and some guesswork.

So now to explain. First use the res:// protocol so that it knows you want to load from a resource. The 2nd item is MyApp.exe and is simply the name of your executable, you don’t have to give a full path.

Now the bit that isn’t obvious. The #2 is the resource type. #2 is for bitmap resources. If you have another type of resource, you’d need a different number. I have no idea how to find out the number for other types, it doesn’t seem to be explained anywhere in MSDN.

Finally the #101 is the resource ID for the bitmap. To find this in MFC you need to look at the file Resources.h, find the bitmap you are looking for and note down it’s resource ID number.

One thought on “Solved – CDHtmlDialog and bitmap resources

Comments are closed.