Blacked-Out Option Buttons

3
Filed under Uncategorized

Here’s an oldie but a goodie.

I hadn’t run into this in years, but here it was, making a nasty return.

Basically, if you’re running a VB6 application under Windows XP, and you have all the XP UI goodies turned on (the default), and your app contains option buttons directly sited within a Frame (pretty typical), the text of the option buttons will be blacked out by nasty black squares.

When I first ran into this, far too many years ago to mention, there was nothing about it anywhere. I remembered looking for several days for a solution before stumbling onto one.

Fortunately, there’s now a good KB article (KB936166) on the issue (though MS never fixed it).

Interestingly, as workarounds, the article offers:

Right-click the desktop, click Properties, click the Themes tab, and then select Windows Classic in the Theme list. Alternatively, click the Appearance tab in the Display Properties dialog box, and then click Windows Classic style in the Windows and buttons list.
Do not put option buttons inside frames.

While helpful, neither of these options would really do much to make my customers happy.

Fortunately, there is a third option:

Site your option buttons in a PictureBox (just set the background color appropriately and frame style to NONE) and then site the PictureBox on your frame.

Everyone’s a winner, and it’s not too terribly stomach-churn inducing.

Upgrading TIVO

0
Filed under Uncategorized

I’d been meaning to upgrade/backup my TIVO hard drive for ages now (it’s actually more than 4 years old, and has been running almost continually in that time).

The prospect was a tad daunting, esp after looking through the Hinsdale How to Guide. I’m not a huge Linux gearhead, but I can find my way around in a pinch. Still, at 26 pages, there’s a lot to absorb there.

In the end, after a good weekend of various false starts, I’m happy to say I now have a 370 hour Tivo with a nice, fresh, cool-running, ultra quiet Western Digital 320gb hard drive. And I was able to preserve all my existing recordings to boot! I probably should have taken the time to setup the FTP daemon or telnet access while the drive was out, but I’ve just run out of time for now.

However, for those considering attempting this, I thought I’d document a few of my false starts to hopefully keep you from traveling down those same paths.

First, the Hinsdale guide contains great info on removing the cover of the TIVO, removing the hard disk, what hard disks you might want to use to upgrade (I happen to prefer the newer Western Digital drives), and the commands you’ll need to move TIVO drive images around.

Also, I’m writing this from the standpoint of upgrading a single drive Tivo with a new, BIGGER single drive. If you’re dealing with a dual drive Tivo, or just want to add a second drive to your Tivo, this page probably won’t help you much.

Steps 1-6

These steps are all spot on and will get you to the point of having the TIVO drive in your PC. Make sure you have a bootable CD of MFSTools (or copy it to a bootable USB drive like I did).

Of course, having a whole step like:

Buy a Tivo

and

Buy a Torx Screwdriver

is a tad overkill, but at least they’re clear on the subject.

Step 7

This is all about making a short and sweet backup of your original TIVO disks. DO THIS!  A VERY IMPORTANT POINT TO NOTE is that when mounting your existing FAT32 drive (that you’ll use to write the backup to), they indicate to use the commands:

mkdir /mnt/dos
mount /dev/hda1 /mnt/dos

Take special note of that hda1. That’s hugely important! I accidentally entered /dev/hda (missed the “1”), and totally trashed the drive I wanted to use for the backup. I had to reformat it to get it back.

The backup command in Step 7 worked just fine for me, but be sure you attempt Step 8 (Restoring the MFSTools backup) before assuming it is a valid backup! See below.

The backup command I used (with a Series 2 TCD24004a Tivo) was:

mfsbackup -f 9999 -6so /mnt/dos/tivo.bak /dev/hdX

where X is the drive ID of the original Tivo drive you hooked up to your PC, typically “hdc” or “hda”.

FALSE START: I originally wanted to try performing the backup on a scratch drive I had lying around. Ie, backup and restore a scratch drive AS IF it was a Tivo original drive, just for practice.

Attempting to use MFSbackup on a non-Tivo drive will just end up giving you a read-block error, so that was no go from the start. Then, I came across the dd command a little later on in the backup section, so I tried it:

dd if=/dev/hda of=/dev/hdb bs=1024k

That ran for hours and hours and never completed. I stopped it after about 8 hours. One reason is that the “source” drive was a FAT32 formatted 120gb drive. Apparently, the dd command is very slow with large drives like that.

Step 8

As I mentioned above, you definitely want to verify that the backup actually worked. It failed once for me (because I didn’t get the command quite right), but it didn’t tell me it was a bad backup.

One point that the guide mentions and I’ll stress is to unmount (using umount -f -a -r) before rebooting and then powering off the machine.

You’ll want to test the restore of the quick backup using the command:

mfsrestore -r 4 -s 127 -bzpi /mnt/dos/tivo.bak /dev/hdX

where X is the letter of the NEW drive that will be going into your Tivo.

FALSE START: there is a paragraph in the guide that starts with “Note for those with already tested image” that basically indicates you should be able to perform a particular restore and automatically expand the Tivo in one shot, if you’ve already tested restoring the image. This didn’t work for me. The command they show to use is:

mfsrestore -s 127 -xzpi /mnt/dos/tivo.bak /dev/hdX

Note the missing -r 4 and the -xzpi instead of -bzpi.

I’m not sure what the difference is, but I do know that the Step 10 instructions below DID work properly.

Step 9

Put the new Tivo drive (that you just restored a backup onto), into the Tivo and try to boot it. This is just to verify that the backup and restore worked.

After working with PC’s so long, it’s a bit strange to work with a device that has no OFF button. To turn on the TIVO, you plug it in. To turn it off, you unplug it!

Step 10

I wanted to preserve setup and recording so I browsed through to the proper spot in Step 10.

Once I hooked the Original TIVO drive AND the new Upgrade Drive (had to take it back out of the Tivo box from Step 9), I rebooted to MFSTools and used this command:

mfsbackup -Tao - /dev/hdX | mfsrestore -r 4 -s 127 -xzpi - /dev/hdY

where X is the letter of the original TIVO drive and Y is the letter of the new Upgrade drive.

Note that the -r 4 is here from the part of Step 8 above that worked. I’m not sure of the difference between -xzpi and -bzpi. ANy ideas?

This command took a LONG time (for a 40hr Tivo, it took about 8 hours), but it does show progress (unlike the dd command), so I knew it was working the whole time).

FALSE START: I thought it might be good to grab a backup of the WHOLE Tivo drive and then restore that, so I tried this command, after remounting my FAT32 disk I was using to save backups:

mfsbackup -Tao /mnt/dos/all.bak /dev/hdX

It ran for a while but then failed for no apparent reason. I probably just don’t have the flags right, but it was 12:30am, so things were getting bleary.

Summing up…

In the end, the single step backup from original disk->restore to new disk worked just fine. Put it back in the Tivo, booted, and now I have plenty of space for Sesame Street and Stargate.

When is a not Dead UPS, in fact, Dead

2
Filed under Hardware

If you’ve spent any time at all on computers, you’re bound to know the frustration of working along, minding you’re own business and getting tons done when, blip, the lights go out for quarter second you’re staring at a black screen, trying to remember what exactly that last idea was that would save the world from destruction, if only you’d been able to write it up first.

A good UPS (Uninteruptable Power Source) can all but alleviate those problems.

But don’t do what I did. I was short on cash the last time this came up, so I picked up a Best Buy special for about 60$, a CyberPower 525SL for my server. Before that, I picked up a Belkin UPS for my workstation.

They worked ok, for a bit. But we got a power flicker yesterday that sent both machines into the black within about 2 seconds. And right at a most inopportune moment. My wife’s PC, on an older APC, never even noticed.

A UPS is one of those things that I almost hate spending money on. The batteries never seem last very long. They can’t be environmentally friendly, and yet you pretty much are guaranteed to throw them out on a regular basis.

But, I hate losing work too.

A little google research later and I’m off to Office Depot to pick up an APC XS1300. 178$ after tax. Big double sealed, hot swappable lead acid battery putting out 1300va for 780 watts. Very cool red LCD screen.

image Here’s a shot of the typical incoming voltage level.
image But here’s the interesting shot. That’s the current load, in watts. Pretty slick. Don’t even need a KillaWatt to measure.

My server reads about 107 watts on average, which surprised me a little because of the 1.5.gb ram, but mainly because of the 4 RAID drives, plus boot drive, plus an extra drive.

My new rules on UPS’s:

  • Make sure it has an easy to swap out battery. This APC’s is hot swappable, and requires no tools to get at. Looks like most APC batteries are hot swappable. The CyberPower and Belkin? Fugettabowdit.
  • Make sure it’s big enough to give you some lead time. Minimum 600 watts for today big Core 2 Duo rigs.
  • Make sure it speaks USB. Serial ports are a rare thing on modern MOBO’s and the chat between UPS and machine is pretty handy for shutting things down intelligently when you aren’t around.
  • Don’t even think about those el cheapo sub 100$ units unless it’s going under a TV or a cordless phone base station. Just the fact that replacing the battery requires tools and time should be the clue there. Wish I’d spent the money way back when.

Any good UPS horror stories out there?

BOOTMGR is missing

0
Filed under Hardware, Troubleshooting

So I’m getting all set to upgrade my TIVO harddisk. I’ve downloaded and burned MFSTools, gathered all the various bits together, etc.

I thought, Hey, it’d be a good idea to try this out on a scratch HD first, just to make sure I know what I’m getting into.

So I grabbed an old 120GB drive, swapped it into my machine, and was going to reformat it as FAT32 and copy a few files on it, so act as a surrogate TIVO drive.

I swapped the drive in, restart the machine….

BOOTMGR is missing

Huh!??????

After some panicked Googling from my server, I discover that Vista has a nasty habit of writing the BootMgr sector to the “first” HD in the drive sequence according to how your BIOS is configured at the time you install Vista.

In my machine, the RAID comes pretty late in the boot sequence, so apparently, my spare 320gb drive that I was intending to use in my TIVO inadvertently picked up the Vista boot manager.

To avoid this whole mess in the first place, make sure when you install Vista, the ONLY HD that’s installed is the one you’re installing Vista onto.

However, if you’re like me, that’s not much of an option. Which leads to solution #2:

  1. Shut the machine down.
  2. Disconnect any “other” hd’s (other than the one that has Vista installed). If you’ve got a RAID, leave only those drives in the RAID connected.
  3. Find your Vista Boot DVD
  4. Put it in and restart, boot to the DVD.
  5. The Vista installer will start up and ask if you want to install in English, etc. Click Next. This won’t actually start installing Vista.
  6. The next screen, towards the bottom, has a “Repair your computer” option. Click it.
  7. Click the operating system installation (there’s likely only the one Vista installation listed). Click next
  8. In the System Recovery Options dialog, click Startup Repair.
  9. Restart the computer.

Worked for me.

Formatting FAT32 Under Vista

0
Filed under Uncategorized

I needed to format a 120GB disk to FAT32 to run a few trial runs with MFSTOOLS for upgrading a TIVO unit with a bigger harddisk. You’ll also run into this, though, if you need to format a USB key, or removable harddisk as FAT32 (so it would be compatible with Linux or a Mac).

You can’t format at drive/partition with FAT32 format greater than 32GB under Vista.

Microsoft has apparently just put an arbitrary limit in the formatting routines.

Not only that, you can’t format FAT32 at all via the GUI, as far as I can tell. The drop down list for format type only shows NTFS.

You CAN format in FAT32 by opening a command prompt as administrator and running

Format {drive} /FS:FAT32

But that’s still limited to 32GB partitions.

I did find a couple of solutions, though.

The first is a freeware command line utility from RidgeCrop Consultants called fat32format.

The second is a GUI utility (but that’s putting it nicely) called Flash HD to GO!, for formatting USB keys, but it appears to work with any media.

They both seem to work just fine under Vista for formatting an actual harddisk (in my case a 120GB Seagate).

I will admit though, the Flash HD to Go utility can be a little nerve wracking to run, with it’s decidedly sparse UI and limited warnings and information about the drive that’s about to go bye bye.

Outlook and Attachment Strangeness

0
Filed under Office, Troubleshooting

Dealing with attachments in Outlook is a bit like entering an Ultimate Fighting match against a professional half-octopus, half-eel. It really doesn’t matter what style of fighting you choose, the octo-eel is guaranteed to take you down more than once in the match, and there’s really no telling whether you have a chance at winning.

An app that I’m working on deals with attachments in Outlook, more specifically, it deals with Office format attachments, so we’re talking about DOC, XLS, and PPT files (and about 2 dozen other *X and *M formats introduced in Office 07).

Anything else (like BMPs, TXT files, etc) are supposed to pass on through like yesterday’s iceberg salad.

However, astute customers noticed that, in some cases, the order of the attachments could change at times. If you had numerous attachments to your email, and you intended on them being in a particular order, that might not go over well.

Now, you might think, with such a nicely laid out object model as Outlook’s, that preserving the order of attachments in a message would be trivial. Hell, you might even thing you could simply replace one attachment with another, simply by using a replace method or somesuch.

And you’d be wrong.

There’s no replace method, unlike GroupWise. And the ATTACHMENTS.ADD method doesn’t allow you to specify an ordinal. It does allow you to specify a position, but that value is only used to indicate the character position of the attachment in an RTF format email. If the email format is plain text, or HTML, the position isn’t used at all.

Then there’s this jewel from the MSDN documentation on the add method.

To ensure consistent results, always save an item before adding or removing objects in the Attachments collection of the item.

Special.

Add to all of that the fact that Word can also be used as the email editor (albeit in approximately the same capacity as the built-in Outlook RTF editor from what I can tell), and you have a whole lot of arms to fight with on this octo-eel.

The bottom line however, turns out to be relatively simple.

  1. First, you have to make a single pass through all the attachments in a message and for every one you plan on removing, you need to add the new one. In addition, for those that you don’t plan on removing, you have to extract them, then add them again anyway, in the same order as they already exist.
    This will cause the email to end up with a double set of attachments; the originals, and all the new ones, plus a second copy of any original attachments you didn’t necessarily want to mess with but have to anyway.
  2. Next, make another pass through all the attachments, removing all of the original attachments, but leaving everything else. Now, the email will contain the proper list of attachments, both new and untouched originals, in the original order, at least for plain text and HTML formats.
  3. For Rich Text, there’s one more trick….
  4. When you add the new attachments (or re-add those attachments you intend to pass through, in step 1 above), retrieve the POSITION of the attachment first.
    If it’s 0, make sure you add the new attachment WITHOUT specifying a position argument. Specifying a 0 for the position will only mess things up.
    If it’s NOT 0, however, add the new element with a position argument of the original POSITION + 1

It sounds more complicated than it is.

If you get any part of it wrong, you’ll know pretty quick. Usually, the attachments will end up in the sent email reversed in order. Worse case, some will end up missing.

One final trick. Testing all this can be a real pain, but you can make it a little easier.

Set up Outlook with POP accounts only (don’t use Exchange for this). Then set it to NOT send email on startup:

image 

Anything you send will end up in the outbox, where you can examine it, use it for debugging, drag it back to the inbox to attempt a resend, or delete it. And from what I can tell, whatever ends up in the outbox is what would go. There’s no additional processing done after that.

Plus, you don’t even have to use a legitimate TO address, anything that looks like an email address will work.

Believe it or not, I actually like Outlook, despite it’s, uh, quirks? It’s been my email system since about 97. I’ve never had a corrupted PST file, never lost an email (that I didn’t unintentionally delete with Shift-Del), and never gotten an email-born virus.

Now, excuse me, I have some serious knocking to attend to. 

Bootable USB Keys

1
Filed under Hardware, Utilities

Maybe I’m jumping on the band wagon a bit late with this one, but it’s pretty slick if your machine’s BIOS will support it.

It IS actually possible to write a boot sector and boot files to those little 256mb+ USB keys that you can get in the gumball machine down at just about any local soda fountain or 10 cent store these days.

Why would you want to?

  • They boot a LOT faster than CD or DVD
  • They’re rewritable without any special considerations.
  • You don’t have to have special burner software to update them (other than what’s required to lay down a boot sector).
  • You don’t have to suck up an EIDE channel just to be able to hook up a CD to boot to.

It was that last part that hooked me. I’m in the process of upgrading a TIVO to 320GB and my shiny new iron only has 1 EIDE port (and 2 channels). One to the old TIVO drive, one with the new drive and, bang, nothing to boot to (You don’t want to boot to Windows with your TIVO drive attached, Windows like to stamp any drives that it can see, which can screw your TIVO drive all to hell).

With a bootable USB key with MFSTools on it, I can boot to the USB, and still have both the HD’s connected to copy and back up between them.

I know, I know. Grab an old machine with 2 IDE ports and my problem was solved. Well, the only old machine I have left is way, way old, and it’s bios doesn’t even recognize the 320gb drive I’m using to upgrade. The other, not so old machine, is just waiting to be hauled to the hazardous waste site, cause it won’t even give up a POST BEEP.

To get DOS or windows on the disk, you’ll need to format the USB Key with a boot sector. The easiest way I found to do that is this HP utility. It should let you format the drive and copy the boot sector over from a boot floppy. Once that’s done, you should be able to grab a copy of BARTPE and build up a fully USB KEY bootable copy of Windows XP, assuming you have a bootable CD of Windows XP. Well, it ain’t a “full” Windows XP but it’ll get you loaded and able to grab info of an otherwise unbootable drive.

To get Linux working, you gotta go deep. You’ll have to use SYSLINUX, and/or ISOLINUX to overwrite the DOS boot sector with a LINUX boot sector.

To get MFSTools working on the resultant LINUX USB key, you’ll need to get the ISO first. Mount it using something that’ll mount ISO images, like Elaborate Byte’s free and excellent Virtual Clone Drive. Then copy the whole thing down to the USB key. This won’t copy the boot sector, though. That’s what SYSLINUX was for.

Still won’t quite work though. You have to copy the contents of the ISOLINUX folder down to the root of the USB key. Then Rename ISOLINUX.CFG to SYSLINUX.CFG. That’ll allow the ISOLINUX image to boot to a ram drive like it does normally when booted from CD (at least, that’s the way I understand it, knowing what I know about Linux at this point).

If all that’s done right, and assuming that your machine supports booting from USB, and assuming you’ve configured the BIOS to allow it, reboot and feel the joy.

If it doesn’t work, take two aspirin, reboot and… be thankful Windows doesn’t require this sort of nonsense….???? Ok. I jest.

BartPE is a very interesting possibility because it’s relatively easy to build and you can add your own Windows tools to the mix (up to the size of your USB key anyway). Could come in very handy for recovery and forensics work. And USB Keys are more scratch resistant than CD’s. Plus, some have that nifty, switchblade action with the USB plug.

image or image

Oh, and one final tidbit for any security oriented people, check this out and see if you get any sleep that night.

Disabling the UAC for Administrators Only (or rather, Not Quite)

0
Filed under Security, Vista

Ever since I disabled UAC on my Vista machine, I’d been hoping for a way to disable it only for specific users.

Then I just stumbled across a promising page for disabling the UAC prompting for administrators only.

It wasn’t the “Per User disabling of UAC” that I was hoping for, but I’d take it.

In a nutshell, run SECPOL.MSC from the Start, Run box

Expand Local Policies, and select Security Options.

Find the entry “User Account Control: Behavior of the elevation prompt for administrators in Admin Approval Mode” in the list (it’s towards the end) and double-click on it.

Change the setting to “Elevate without prompting”.

Note that this won’t work with Vista Basic and Home, because those versions don’t come with the SECPOL.MSC file. Check out the blog above for a reg script for that.

So, then, I thought,  just setup an Admin user for doing standard development stuff (where the UAC is just a flat pain in the ass), then, login as a NON-ADMIN user with UAC enabled to test things out.

Well, not so fast. Turns out, even with the Automatic elevation setting on, elevation still doesn’t happen quite right in all cases. Take for instance, Winternal’s Process Explorer:

image

That Replace Task Manager option will cause a “Process Requires Elevation” prompt with UAC enabled, regardless of the “Elevate without prompting” setting mentioned above, so there’s more to this that what would appear to be mentioned in the help for that security option. Granted Process Explorer is pretty low level stuff, but it’s something I use all the time.

Screw that. Not worth bothering with, so off goes the UAC again.

Sucking up 80 Columns of Code

3
Filed under VB Feng Shui

There’s an interesting discussion on SlashDot asking the question of whether we collective programmers should drop the old “80 column” standard that’s still so prevalent and go with some larger number, say 132, or, possibly something even bigger.

With the new widescreen displays, this would almost seem to make perfect sense.

But I think I’d side with the majority of posters that 80 columns is more than enough in most situations. Besides that, there are very good reasons that newspapers and magazines don’t print articles the full width of the page, but instead create columns. The eye just has a hard time sucking up that much stuff .

In the typical programming book I have, I counted an average of about 74 chars per line (proportional, so the number could vary, though not by much). In the paper back books I checked, I see about 54 chars per line. These are single column books.

80 would seem just about right. Long enough to deal with the typical indentation of a programming language, but short enough to keep you from getting lost on the line.

Besides, other than those lines with long tables or strings of text, why would you create a very long line of code? C is pretty notorious for allowing such nonsense with it’s ? operator and inline assignments, but there’s very few that would argue those things make the code more readable. VB has it’s “:” statement separator, but there are very few instances where I’ve seen it put to particularly good use.

Convention generally holds that you want to stick to one statement per line. And typical statements should be far less than 80 chars long.

On a related note, I have a few other questions to throw out

  • How many spaces should a tab comprise?
  • Is it better to program black on white or white on black?
  • Do color coded syntax highlighting editors actually help or just distract?
  • Should web pages go columnar when the chars per line exceed some number (for instance, browsing full screen on a widescreen monitor)?

For me, it’s:

  • 3 (2 is too few to be visually distinct, and 4+ takes up too much line space),
  • White on Black (with a white background, there’s just too much light coming at me. It’s almost blinding to run an editor full screen on a 24″ widescreen with a white background.
  • Not much, although I do tend to color comments in a dimmer color than the rest of the code. Everything else I tend to leave as white text, unless it’s a very specific file format. For instance, I have coloring rules for INI files and XML files to highlight the sections, keynames, and element tags.
  • Up in the air on this one. On slashdot, maximized, I count about 230 chars per line on my widescreen monitor. They run as a single column and just stretch it out to accommodate the browser. Many news pages simply limit the max width of the page to somewhere around 1024 pixels or so. Here’s a typical MSN page maximized on my system:

image

That seems like a waste to me.

Vista’s New Recursive Folder Structure

4
Filed under Vista

How’s this for a peculiar error message:

image

This one is from FileBackPC (a normally awesome little backup app). I can configured a rule for my server (which runs FileBack) to reach out to each of my workstations and grab a backup of certain folders, including the entire user profile.

There’s the rub. Apparently, Vista creates a hardlink from the “Application Data” folder back to its parent. This results in a recursive folder structure that is guaranteed to give fits to any app that recursively traverses the dir structure.

Vista itself appears to “know” what’s up though. You get this if you try to navigate into the Application Data folder via Explorer:

image

This same technique works great with XP. In the FileBack, I just had to reconfigure the rule to not traverse into that folder. Other apps might not be so obliging.

Sigh. Yet another one of “those little issues.”