Monthly Archives: August 2011

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.

Dead Easy Pure CSS Button Class

Here’s a really simple way to make a styled button using only CSS. I wrote this because a lot of the “Pure CSS Button” scripts I found on the interwebs use a PNG image for the button which is not pure enough for me dammit!

This one does not use any image at all which is good for saving space if you are, say, working on an embedded web server with only a few kB of storage. It is also quick to set up. Simply cut & paste the following lines into your CSS file and add class=”button” to your tag in the HTML.
.button {
font-size: smaller;
background: #CCCCCC;
padding: 3px;
border-top: 1px solid #EEEEEE;
border-left: 1px solid #EEEEEE;
border-right: 1px solid #666666;
border-bottom: 1px solid #666666;
text-decoration: none;
}

.button:active {
border-top: 1px solid #666666;
border-left: 1px solid #666666;
border-right: 1px solid #EEEEEE;
border-bottom: 1px solid #EEEEEE;
}

And here is an example of a link using this style:
Go to Other Page

Here is what it looks like: Test Button – how easy was that!