App Compat Bug Explained: The Mysterious Black Background in Visual Basic 6 (VB6) Forms and Controls
Published Aug 14 2018 04:13 PM 2,170 Views
Microsoft
First posted to MSDN on Apr, 18 2010

Here is an issue I see pop up sporadically, so I figured I would spend the time to dissect how it happens: an application appears to work great on Windows XP, but when you run it on Windows 7 (or Windows Vista), it has a strange black background which used to be white. How does this happen?

Well, it’s not purely random – Windows just does what it is told, but I figured I would explain why we ended up with this.

First, let’s fire up Visual Basic 6 on Windows XP. Create a New / Standard EXE project. Form 1 pops up.

Now, let’s say we wanted to fiddle with the color of the background of that form. In Properties, go to BackColor, and then click the down arrow. Let’s say you like white, because it’s the new, modern color instead of that old Windows 2000 battleship gray, so pick the FIRST white color you see…

Oh – my … looks like the FIRST white colored option I see, without having done anything special, is Active Title Bar Text. (That’ll always be white, right?) So, let’s pick that one.

And guess what happens? You have a form with a white background on Windows XP (with the default Luna theme), but suddenly has a black background on Windows 7. (If you’re using Windows 7, have a look at your title bar right now – unless you’ve fiddled with it, there is black text with a transparent background – blue if you don’t have DWM enabled.)

Here it is with the Luna theme:


Oh, and just so you don’t think it’s a Windows 7 or Windows Vista bug, let’s try it with the Silver theme on Windows XP:


And we’re doing precisely what the developer asked us to do – setting the form color as the Active Title Bar Text. But, if you look above, the developer probably didn’t ask us that intentionally – he or she probably just wanted white. It’s just that, inconveniently, they accidentally picked a system color since that’s what we show by default, and specifically selected a system color that tends to change rather a lot, and in a way that can render their form illegible.

Unfortunately, we don’t have a shim for this today, so if you are a victim of this, you can either change the code (the ideal mitigation) or, and I hesitate to say this, but you can change Active Title Bar Text. Having done this myself, I can vouch for the fact that it makes Windows look awful, and is a rather drastic step to fix an old app, but it’s an option (of last, last, last resort – please forget I even mentioned it). Or, you can just run it in XP Mode / MED-V / Citrix / etc.

Version history
Last update:
‎Nov 13 2018 08:14 AM
Updated by: