Saturday, July 21, 2012

Yet Another IE Reflow Workaround

IE6-7 will often forget to reflow elements if you give them position:relative or position:absolute and you're updating the DOM of that area. This means your positioned elements disappear, but with a tool like IE Web Developer, they show up immediately after a change is made to the CSS. I've seen lots of different solutions to this on the Internet and most of the time, I have worked around this problem by removing positioning on the elements. For those times when you can't, there's this:

     *z-index: expression(1);
     *z-index: auto;

Triggers reflow! If overflow:hidden on the container, <div></div> before the positioned element and the various other tricks on the Internet haven't worked for you, try this. I'm not sure exactly what's happening, but I imagine it's something similar to me toggling a value using IE Web Developer. It seems declaring a CSS expression is enough for IE to evaluate it and render that element with known attributes up to that point, then after that, IE evaluates the regular property as a change, triggering reflow.

The above works if you're simply adding/removing nodes from the DOM. If you're using hover effects, you might want to try something like this:

     *z-index: expression(_ = +new Date() % 2);

Same principle, but IE is evaluating it constantly, so it'll reflow when you hover over it. Note: Might kill performance.

Saturday, May 21, 2011

Backgrounds Automatically Converted to Low Quality JPEG

If you right-click on an image file and choose "Set as desktop background" or use the Personalization control panel applet to select a background image, Windows 7 will convert the background image to a low quality JPEG often introducing nasty artifacts around outlines. The following method is more of a workaround than a solution. It allows you to right-click on any bitmap image (.bmp) and really set the desktop background to that image.

In an administrative command prompt, type:

reg add "HKCR\SystemFileAssociations\.bmp\shell\setdesktopwallpaper\Command" /ve /f /d "reg add \"HKCU\Control Panel\Desktop\" /v Wallpaper /d \"%1\" /f"

reg delete "HKCR\SystemFileAssociations\.bmp\shell\setdesktopwallpaper\Command" /v "DelegateExecute" /f

(If you're feeling lazy, run the batch file instead.)

Now, if you right-click on a .bmp file, choose "Set as desktop background", log out and log back in again, your desktop background will be the exact image file you selected (no transcoding).

Note: Opening the desktop background page of the Personalization control panel applet will transcode whatever image you've selected. To keep the image as your background, you'll have to set it as your desktop background again after closing the applet.

If anyone has a more comprehensive solution, I'd be very appreciative.

Sunday, April 17, 2011

Unable to Turn On .NET Framework 3.5.1

If you receive the message, "An error has occurred. Not all of the features were successfully changed." when trying to turn on the .NET Framework 3.5.1 Windows feature in Windows 7, the following may help.

In an adminstrative command prompt, type:

cd %SystemRoot%\Microsoft.NET\Framework\v2.0.50727\CONFIG
copy machine.config.default machine.config
copy web.config.default web.config
copy web_hightrust.config.default web_hightrust.config
copy web_lowtrust.config.default web_lowtrust.config
copy web_mediumtrust.config.default web_mediumtrust.config
copy web_minimaltrust.config.default web_minimaltrust.config

(If you're feeling lazy, run the batch file instead.)

Open the Windows Features control panel applet and try turning on .NET Framework 3.5.1 again.

After perusing "CBS.log" in "%SystemRoot%\Logs\CBS", I discovered that the built-in installer of .NET Framework 3.5.1 expects to find these files properly configured. If it can't, it rolls back the entire installation and prompts you to restart (?!). Luckily, .NET 2.0.50727 comes packed with .default files that are templates for real configuration files. The batch file above just makes copies of these files.

I'm not sure exactly what brought about this conundrum. It may have been the .NET Framework Cleanup Tool, or some other such "helpful" utility. Either way, it's solved now and I can continue to customise the Windows 7 logon screen using the dirty .NET-based tool presumably built by a twelve-year-old that I found.