Transparent Icons

by Jim Jul 19, 2006 5:56 PM

I was creating a fancy new icon for a program I'm working on, and noticed that it sometimes wasn't displaying correctly. After a little testing, I determined that in certain situations, Windows XP does not correctly render partially transparent pixels in a 16x16 icon.

Sometimes pixels with anything less than full opacity are rendered as transparent. Depending on the icon and how it is drawn, this may be hardly noticable. But here is my test icon:

First is the Explorer thumbnail view, second is what the icon looks like in the list or details view - that's the correct rendering.

The icon is correctly upsized to 32x32 for the icon view in explorer, and native 32x32 icons don't appear to have any problems.

Lesson - minimize use of partial transparency in 16x16 icon formats.

Tags:

404 Exceptions

by Jim Jul 18, 2006 10:07 PM

One of the rules of exception handling is to not use exceptions as flow control devices. If an exception can be anticipated, avoid it by testing for the problem condition in the first place.

That's fine, until the .NET framework doesn't give me the option of testing for the condition. I want to use WebClient or WebRequest to get a file from a web server, if it exists. But, there's no way to test for the existence of the file without throwing an exception! The server returns headers and a response stream for a 404, just like any other request - shouldn't I be able to suppress the exceptions and check for the 404 myself?

It's only going to happen a few times in my application, so maybe it's not so bad. But it's still ugly.

Tags:

DIV Layout

by Jim Jul 07, 2006 6:56 PM

I love DIVs. I hate tables - except for tabular stuff, then they're OK.

DIVs can be frustrating to work with sometimes, though. I've been seeking the perfect layout for my website and blogs. There are a lot of examples online - this guy has some great designs. But none of these were working for me. My "holy grail" of layout is a two-column design.

Typically a layout like this would expand with the page, which can get weird at extremes of screen resolution. Or, it would have a fixed width, which doesn't work well when the content gets too big - do we chop off the extra, or let it hang over onto the background?

I have pages that (sadly) have very little on them, and others that have too much - images, or especially code snippets with long lines. I want a minimum width and height for the central DIV, so that it looks nice and aligned with small amounts of content. But it should fail gracefully - that is, expand with the content, such that the whole screen scrolls, never the content box.

Oh, and it has to work in Firefox and IE. This is what we call "non-trivial." This little style sheet fix for differing interpretations of min-width and min-height helped. After a bit of searching I finally found the magic property among the obscure values for the CSS display property, which makes a DIV expand with content in Firefox.

You're looking at this layout - at least until I redesign the page. Again. It's a learning experience. Here's a cleaner example.

Tags:

Reformatting with AJAX

by Jim Jul 06, 2006 9:42 PM

AJAX is a technology whose intended (or typical) use is to exhange small amounts of data with a server, from javascript on a web page, so that the page can be updated without reloading the whole thing.

Not long after I heard of this, it occured to me that it can be used to load HTML from any page, and then reformat it, with all the parsing occuring on the client. There's no parsing happening on the server, so a lot of people can view the reformatted page, with all the processing happening on their machines. In fact, the script that does the parsing doesn't even have to be on any server. Of course, the HTML has to come from somewhere, but we're shamelessly grabbing someone else's data and reformatting it. :-)

Because we're using AJAX to get data from a different domain, Internet Explorer 7 warns you about a security risk. It looks like Firefox and IE6 won't allow it at all. This seems a little too restrictive to me - it seems reasonable that a company might operate servers with seperate domains. I suppose the designers though it more likely that someone like me would want to see data and not adds.

So here's my little page, if you have IE7:

I didn't like the way the live Tour de France feed worked - the latest entry is always at the bottom. This won't look like much unless the the tour is actually happening. (The link in the header is the original page.)

Tags: