Archive for the ‘ Programming ’ Category

Supporting IE is still a thing.

An interesting tidbit I came across today.

Apparently Internet Explorer won’t make an XMLHttpRequest from a given security zone into a more secure zone. It makes perfect sense, but I spent a ton of time figuring out that it wasn’t a CORS issue. I even spent a bunch of time looking into P3P – blech. I didn’t even realize the sites were in different zones until I had a eureka moment.

An actual update

Hmm, I haven’t posted here in quite a while. Oh well.

I was working on a utility a couple days ago to help me verify the checksums of a large set of files to help prevent against bit rot. Basically, it is a beefed up version of md5sum which can operate on an entire directory tree and update the checksum database somewhat intelligently.

Perhaps someone will find it useful – I decided to post it on github.

Creating an alpha-blended cursor in Win32

MSDN has a fairly nice article about how to create an alpha-blended mouse cursor in Win32.

You can read the article at

The long and short of it is that you create a BITMAPV5HEADER structure to describe your bitmap, then you call CreateDIBSection to create a DIB to hold it, then copy your pixels in, and bam, it works.

Well, most of the time.

I’ve spent multiple hours today wrestling with this code which wasn’t working for me. I couldn’t get the alpha channel to work properly. At first I didn’t think the code worked at all, but with some input from others, I realized that the code did work exactly as it was listed, but that I had modified it a little.

Specifically, I was trying to alter the byte ordering. The BITMAPV5HEADER struct has 4 parameters, bV5RedMask, bV5GreenMask, bV5BlueMask, and bV5AlphaMask, which ostensibly allow you to configure which bits in the bitmap correspond to which colors.

The example, as given, was arranging the bits as AARRGGBB, which I believe would typically be called BGRA and I believe is typically the default on Windows due to its little-endian nature. However, the bitmap I wanted to use as a mouse cursor was arranged AABBGGRR (RGBA) as it had its origins in OpenGL land.

After wrestling with this for hours, I came to a conclusion. You just can’t use an RGBA bitmap to create an alpha-blended mouse cursor. I haven’t gone to the lengths of testing if you can create an RGBA HBITMAP at all (my guess: no), but it definitely does not work for mouse cursors. No way, no how, no amount of beating it with a stick. It won’t work.

I had to end up coercing the bitmap to BGRA (which isn’t hard, or all that expensive, but irritating), and now it works fine.

My guess is that there is some sort of optimization going on deep under the hood, but unless Microsoft wants to speak up about it, I doubt I’ll ever know. I just wanted to get this information out ‘on the webs’ because Google was sure failing me all day when trying to research the problem.