September 15, 2005

(Tool)Band Aid

So, I recently completed writing a Desk band for windows. What is a desk band, you ask? Well, your windows start bar is the home for several desk band objects. These are basically COM objects that support a bunch of interfaces and register themselves in appropriate places so that windows knows to load them.

In short, you register your windows class and it gets put in the toolbar. Nearly the same code can work in multiple places in IE, Explorer, and in the Start Bar. So, I learned a few lessons:
  • It is far easier to do your initial development so the band will work in the IE toolbar than in the start bar. This lets just run the COM object (and automatically start IE) rather than manually starting up the desk band, and attaching to the Explorer process. When you get most of what you need done, you can test it in the Start bar.
  • A conditional compilation switch in your code will make sure that you don't accidentally register the release version of your desk band object to run in IE (if you don't intend it to).

So, I based my deskband on the sample SDK code from Microsoft. But it has a few problems.

  • It registers fine. The normal "regsvr32 myobj.dll" works great, but it doesn't implement any unregister functions. You have to write those yourself. Now, I know that if you use ATL or MFC that you can get that for basically free, but it seems a bit of an overkill if you are doing just a small simple COM object. And besides, you have to do custom registration for it to get loaded automatically anyway.
  • The window with the text is kind of ugly. I really wanted a desk band that didn't have a big square box.

So, here's what I did to get rid of the box...

First of all, I registered the window class with a background color of NULL. That way, it won't automatically erase the background with blue. I also changed the flags so that there isn't a black border around the window contents.

The next thing I did was implement a handler for the Erase method that windows will call whenever the window needs to be erased. MSDN says that you should do this. If you don't do this, you'll get text that writes on top of itself over and over, works fine until your text changes. Then it looks like some kid scribbled on the screen. But at least you have the same background that the toolbar has. (there are some people that don't use the blue jelly toolbar, they must like grey).

So, how do we keep the nice gradient, or the grey background, or whatever they have as a background while we're drawing on it all the time? StretchBitBlt. Enough said.

... What? That wasn't enough said?

Ok, so here's what I did. realizing that the gradient is vertical, when my erase event gets invoked, I just stretch bit blit whatever is on the left hand side of the draw window all the way across my drawing rect. Then, I text out on top of that. It's easy once you figure it out.

September 14, 2005

Windows XP ala' Burger King (have it your way)

I got my Shuttle SN25P XPC on Monday from NewEgg and immediately put it together. The components that I had delivered with it are:

  • AMD Athlon X2 64 3800+ processor
  • 2 GB Crucial pc-3200 memory (2x 1GB)
  • Samsung SATA2 250 GB drive
  • Gigabyte Nvidia GeForce 6600GT 128 MB video card

Then I spent most of the evening installing Windows XP, service packs, and all kinds of hot fixes. Not to mention the drivers needed by my machine (like everything!) Well, to make a long story short, the UN-service packed version of XP doesn't recognize drives over 130 GB or so, so it formatted the drive smaller than it should have been. So now I'm faced with resizing the drive with partition magic or something similar.

I could have saved myself a lot of time using the following utilities and programs:

The Unattended XP CD link has links to everything else that you need, but also is a good reference by itself. However, for casual use, I recommend just using nLite's options along with your own Windows XP sp2 CD and RyanVM's update pack and the DriverPacks.

And of course, once you have minimized the size of the installation, you can also install it from a USB memory stick using a free utility from HewlettPackard

Most excellent!

September 13, 2005

Jack of all trades...

I guess if Brent can do it, so can I. After much coaxing and goading, I am going to keep a blog of cool stuff that I figured out. This is not so much a vanity site, I really don't believe that anyone will read what I have to say as it is my anti-altzheimers mechanism of choice.
Or, to put it another way...

"Cool. Why don't you put that in a blog so that when I ask you how you did it a year from now you won't just give me a blank expression" - Brent

Oh, yea, and Scott has said almost the same thing from time to time.

Now, for those of you who don't know me... What are you doing here? You must really be bored.