You uncultured flu bug!

Well, this is highly inconvenient.

I show up at the hospital with my oldest son, to trade places with my wife for the night. I go to enter the hospital, and a security guard stops me. "He can't go in," he says, indicating my son. "The hospital is on lockdown. Parents only, no siblings."

"When did this start?"

"About an hour ago."

Apparently, because of the swine flu, they are closing down access to the hospital to necessary personnel only, and that means only parents, no siblings or other visitors.

I call my wife, who is up there with my middle son (the patient) and our youngest son (the terror that flaps in the night). She hadn't heard about the lockdown yet. I told her she needs to meet us downstairs to do the swap.

As I'm waiting, I realize just how inconvenient this is going to be. When my wife comes to relieve me in the morning, she will be unable to bring the toddler with her. And because I have to work, that means he'll need somewhere to stay pretty much all day. So I talk to the security guard to ask about the nature of the lockdown and how long it'll last. The security guard, after assuring me that there is no instance of flu at this hospital, says they don't know how long. Could be a couple of days, could be a week, could be a month.

My wife calls me soon after. She of course had the same thought, and she was talking with the charge nurse to discuss our options. (The security guard also suggested I could try talking to the charge nurse for the same reason.) Apparently, in talking with the nurses inside the hospital, she learned there was a case of swine flu detected in the hospital. It wouldn't surprise me if the security guards at the entrance were told (or instructed to tell people) there wasn't, but it also wouldn't surprise me if the "fact" that there was wasn't just a rumor that was going around the nurses' stations.

My son (the patient) had just been coming down with a cough and congestion. Wouldn't it be just our luck if it was him who had come down with the swine flu, on top of whatever else had brought him there in the first place? My mother had, after all, just come back from a trip to Mexico before she came to spend a weekend in the hospital with my son.


WordPad: "Picture" = "End of File"?

There's this annoying bug in WordPad in XP that I'm surprised I couldn't find very much about. But it's hit me on more than one machine (and I never seem to remember it until after it happens, of course).

Whenever I create a document and I paste a picture into it from the clipboard (usually copied out of Paint, as that's a convenient way for me to get an image on the clipboard in a hurry), the picture and any text after it is not saved with the document.

This time, naturally, it happened to be on my set of release notes for a product release, where I happened to add a picture to the beginning of the document. Entire document, gone.

It seems to be a function of WordPad itself adding the picture to the document. If I open a document that already has a picture (e.g. by creating a document with a picture in Word and saving it as RTF), I can do just about anything to the document, including cutting and pasting the picture to other locations. It's just the act of initially adding that picture to the document that makes WordPad stop processing.

Why use RTF at all? Well, RTF is a very convenient format for creating simple text files that have a little bit of formatting. They're also extremely portable — whereas Word documents (or documents saved in "Word-compatible" formats) can sometimes display oddly in different versions of whatever you're using to view them, there's so little in an RTF that you're almost always guaranteed you'll see the text and its formatting as it was intended, without any attempt to dictate margins or other unimportant stuff. It makes it very handy for distributing a simple document to clients that look decent, don't require any extra software to display (they will at least have WordPad, if not something bigger; I can't guarantee they'll even have a PDF viewer, or a DOC viewer for that matter), yet has just enough formatting to be "professional" (as opposed to plain text). It can also be embedded in a Windows Installer, which is part of my goal here.

Why use WordPad when I have Word installed? Well, my goal is to have a very simple file, without extra garbage or formatting codes. Creating a particular file in Word, which includes a single 24x24 picture, and saving it as RTF resulted in a 53kB document, which, if you look at in a plain text editor, you can see over 7k of format codes defining (among other things) fonts that aren't even used in the document, before the first line of actual text. Merely opening that file in WordPad and saving it (which has the effect of stripping out all the garbage, taking it down to the bare necessities) results in an identically-formatted file that is 15kB. (Unfortunately, it doesn't replace Word's "smart quotes" with standard ones.)

I remember taking a Word 2.0 document, opening it up in Word 6.0, and saving it, with no changes, and noticing the file size balloon to four times its original. So the inefficiency in Word's file formatting comes as no surprise.

Workaround: I played with this a bit before publishing this post, and I figured out the solution. If you go to the Edit menu and select "Paste Special…", you can paste the image as a Bitmap, a Picture (Metafile), or a Device Independent Bitmap. It seems the default, Bitmap, is the one that causes the problem, as selecting either other option works fine. Of course, the Edit menu is the only place this "Paste Special…" option is available, as right-click only shows "Paste" and Ctrl-V/Shift-Ins use the default option.

I tested this in Vista and the public beta of Windows 7. Copying a picture out of Paint in Vista, the default Paste in WordPad worked just fine. Paste Special showed "Unidentified", "Picture (Metafile)", and "Device Independent Bitmap", and all of these worked. I was able to get "Bitmap" as an option in Paste Special by taking a screenshot, but that, too, worked without a problem. Windows 7 had almost the exact same results, except that Paste Special with what was copied from Paint actually listed "Paint Picture" as the first option. Everything else worked pretty much the same (except for having to deal with that annoying "ribbon" toolbar in both Paint and WordPad).

So, I guess, the fix for being able to paste bitmaps in WordPad without losing the rest of the document, is to upgrade to the latest version of Windows.


Fixing the DataGridView's CalendarColumn sample

In a DataGridView, it is sometimes convenient to have a column that is a DateTime that allows a user to use the standard DateTimePicker control for choosing dates. Microsoft has a code sample for a CalendarColumn class that does this, and it's more or less the standard.

Except if you actually try to use it in a WinForms application, you'll find it has two rather glaring flaws:

  1. If you try to type in a date, and you don't type in a full two digits for the month or date or four digits for the year and then tab out of the control, your change won't be committed.
  2. If you type in a date or part of a date and tab through to the same column in the next row, and you start typing, the first field highlighted (month, date, year) will be the last field highlighted when you left the last row. (Example: you type in "04/04/2009", tab until the next row's date column, and start typing "04", you'll find you're editing that date's year.)

I found this forum thread that addresses the first concern. ALight's answer involves adding an event handler to the DataGridView's CellValidating event. Because we use grids all over the application, it would've been very inconvenient to alter every grid and add this code. Instead, since our grids are built dynamically, I did it by adding this code to the CalendarColumn class (that inherits DataGridViewColumn):

protected override void OnDataGridViewChanged() {
    if (this.DataGridView != null) {
        this.DataGridView.CellValidating += new DataGridViewCellValidatingEventHandler(CalendarDataGridView_CellValidating);

protected void CalendarDataGridView_CellValidating(object sender, DataGridViewCellValidatingEventArgs e) {
    if (sender is DataGridView) {
        DataGridView dgv = (DataGridView)sender;
        if (e.ColumnIndex >= 0 && e.ColumnIndex < dgv.Columns.Count
            && e.RowIndex >= 0 && e.RowIndex < dgv.Rows.Count) {
            if (dgv.Columns[e.ColumnIndex] is CalendarColumn && dgv.Columns[e.ColumnIndex] == this) {
                if (dgv.EditingPanel != null) dgv.EditingPanel.Select();

When the CalendarColumn is added to the grid's Columns collection, its DataGridView property is updated, and this routine fires to bind the method to the grid's CellValidating event. Multiple columns will cause multiple event handlers to be bound, but the dgv.Columns[e.ColumnIndex] == this part of the if statement should ensure that only one instance will run the code for any given column. (Note that I have not tested this in cases where columns may be removed from the grid. It should probably work fine, as the event will still be bound and still fire, but the column will never match.)

To solve the second problem, I did some experimentation with the existing control methods. In Microsoft's sample, there is a comment in the CalendarEditingControl's method PrepareEditingControlForEdit that reads "No preparation needs to be done." I found this to be not quite correct. The following change resets the control so, when you start typing, you start editing on the month, like you'd expect:

public void PrepareEditingControlForEdit(bool selectAll) {
    if (selectAll) base.RecreateHandle();

Seems to work so far, anyway.


When ya gotta go, ya gotta pay

Another old post I for some reason never got around to publishing. I was talking to my mother about her experience flying out here (she was able to fly out for the weekend and give us a break from spending time at the hospital, where my son still is with an unknown diagnosis):

The idea that this is even a question to be considered is reason enough to swear off flying.

Flying out here, my mother did of course have to pay extra for something extra she brought us that she had to check. Compared to a flight down to Mexico she had not two weeks earlier, when they didn't charge for extra weight per person (one of her party did have an overweight bag, but they averaged the weight of all bags for all fliers in their party, and they didn't have to pay), meals on the plane, or even alcoholic beverages for the passengers.

It reminded me of a comment I read on someone's blog a while ago. They wondered when airlines started to charge extra for just about everything and hid behind rising fuel costs as the reason, that, if fuel costs were to go back down, would these extra costs go away? Well, I know I'm back to paying under $2 per gallon of gas, and airlines are still charging for whatever they can get away with.

I know I've said it before, but it's a large part of the reason why, even when gas prices were at their highest, my family and I drove out to California instead of flying. If it's just me for a weekend trip, I might consider it. For my family, no way.


This was an old post I started to write a couple months ago. Not sure why I didn't publish it, but considering the project in question has come to an end, I can pretty much call this issue "closed as unresolved".

I thought I was close in finally being able to send an email with an attachment using the default email client in C#. The code that I found worked great when I gave it a quick test on my work machine with XP Thunderbird. It also worked on my development machine running Vista and Live Mail. But when I set up a vanilla XP virtual machine for testing, Outlook Express failed with a message "One or more parts of this message could not be displayed".

Well, at the very least, I could insert the code, and make it a configurable option so I could switch back to the old crap way of using a mailto: link if it doesn't work for the client.

Just my luck, the client recently replaced his old desktop PC with a Mac, and he had his own vanilla XP virtual machine for running Windows software. Sure enough, the mail code failed just as spectacularly in that version of Outlook Express as it did on mine.

Your mouse has moved. Reboot now?

So, to "fix" the problem with my HP tx1420us laptop that sucks in that it no longer recognizes the fact that it has a wireless network card installed, I went out and bought a USB Wi-Fi adapter. I found some online for about $20, so when I went to Best Buy, that was my target price. Unfortunately, they didn't carry any that weren't under $50. Wal-Mart, however, had a Belkin 802.11g for $30, and that was close enough for me. (The one installed in my laptop is 802.11n, but my access point is only a "g" anyway.)

I first installed it in my Windows 7 beta partition, and the installation went very smoothly. Unfortunately, though, I still had to re-configure my wireless settings — apparently, Windows 7 binds wireless configurations to the adapter, so my home WAP's configuration bound to my Broadcom card was not accessible. Not a big deal, though.

Then, I figured I'd better install the software on my Vista partition as well, before I put the CD away. One of the things they tell you to do is to install the software from the CD first, and then plug in the USB device. So I pulled the adapter out, rebooted into Vista, installed the software, and plugged in the adapter again when it prompted me. Again, I had to reconfigure my wireless settings — the binding of settings to adapter must've been a Vista thing that Windows 7 inherited.

That finished, I rebooted into Windows 7. The network adapter was detected, but it did not automatically connect to my WAP. When I pulled it up, I saw that "Belkin USB Wireless Adapter #2" did not have any wireless configurations assigned to it. Apparently, what happened was, when I was installing it in Vista and re-attached the adapter into one of the two side-by-side USB ports on the back of my laptop, I plugged it into the one other than the one I had first used for Windows 7. When Win7 booted, it found the adapter not in port #1, but in port #2, and therefore it assumed it was an entirely different adapter. (Funny, these things are supposed to have unique hardware addresses; it couldn't detect it was the exact same adapter, just moved?)

So now, when I reboot into the other environment, I have to remember to switch the USB ports for my wireless stick. Or just define the same profile for "Adapter #2". Either way, it just seems obnoxious.


No more HP laptops

My wife and I got matching HP tablet PCs a year ago. (The HP Pavilion tx1420us, in case you were curious.) They sure seemed like a good deal at the time, at half the price of most other tablets. At first, I thought the only reason for the price difference was the screen — these Pavilions used a "passive" touch screen instead of an "active", so they didn't track the stylus; you had to physically tap the screen for anything to register. Unfortunately, it seems the cheaper cost has more to do with the quality of the components.

Apparently, there are compatibility issues with the components used such that, after some time, the computer will simply refuse to detect the existence of the Broadcom wireless card. Trying to find it in the device manager, it's completely gone. My wife's was the first to go, and fortunately it happened quickly enough that it was covered by warranty. Mine held on quite a while longer, until just after the warranty expired.

Since I dual-boot between Windows Vista and the Windows 7 beta, I can pretty definitively confirm it is not a software issue — the wireless card disappeared from both OSes at the same time.

A quick trip through the HP support forums revealed that this problem is far from uncommon, with this and similar product lines, and HP is somewhat less than forthcoming with support, especially after the warranty period.

I did find a support bulletin that seemed to address this problem and offer extended support, but of course it did not include my exact model. They say there is a BIOS update that will help protect against it if you don't have the problem yet. The speculation in the forums is, this will only postpone the problem until it is out of warranty, not fix it. I take that with a large grain of salt, but my own experience does make me suspicious. I tend to keep my hardware more up-to-date with drivers and patches (except for the video driver, which for some reason seems to make things worse on this machine when I try to update). So, my laptop is already running the most current BIOS. My wife's was not. Her wireless NIC failed in-warranty, mine waited until it was out of warranty. It's certainly a suspicious coincidence.

I did give HP support a chance. Two identical notebooks, purchased at exactly the same time. One's wireless card failed after six months, one at 13. The one that failed at 6 months was repaired under warranty, and the one that failed at 13, they want $99 to repair it.

"No, I'm not going to pay to repair it," I told the US customer service rep with the thick southern Asian accent. In fact, this will be the last purchase I make from HP.

Incidentally, this post was made on a 5-year-old IBM ThinkPad T40p that was at one point dropped on a hard tile floor. Had to replace the battery after that, but it still runs great. :P


At least he didn't have to go far

So while I'm in transit to the hospital to meet my wife, I get a call. "We'll be in the ER." Apparently, while they were waiting for our son to get prepped for another CAT scan (after one week in the ICU, they still have not been able to positively identify the source of his illness), our toddler slipped, hit his head on a counter, and cracked his head open.

Considering he doesn't have a "slow" speed setting, I had always pretty much assumed it wouldn't be a matter of "if" for him, but "when". I suppose there are worse places for something like that to happen than a hospital.

And maybe it would teach him to slow down and behave? Pfft, not by a long shot. My wife reported that, while they were in the ER waiting room, with his bleeding head bandaged and waiting to be sealed up, he was still running around and climbing all over things.


Looks like I picked the wrong week...

Well, this week has certainly been… "interesting."

My second son came down with a fever last Thursday. When he had a sore throat, we took him to his doctor, who checked for strep, but didn't find anything. When he broke out in a rash over the weekend, we went to the doctor again, who diagnosed it as a rash that sometimes occurs when the fever breaks — indeed, his temperature had dropped that day. By Monday, though, he was still feverish (his temperature kept randomly spiking), and he had barely eaten or drunk anything since the fever first hit, so I called a friend to assist me in giving him a priesthood blessing. On Tuesday morning, he started having severe stomach pains, and my wife took him to the doctor. She then called me at work to say, "Can you meet us at the Children's Hospital ER?"

We spent most of the day in the ER. They did X-rays and a CAT scan to check for appendicitis and any other internal injuries that might have required surgery, but everything came up negative. Eventually they decided to check him into a regular hospital room, but at some point before admission they changed their minds and checked him into the ICU instead so they could monitor him more closely.

I spent the night at the hospital with him there, and the next morning my wife came to switch places with me while I went back to work. His blood pressure was dropping, so they decided to operate to install a more direct blood pressure monitor. In the meantime, we decided to get him a Nintendo DSi to try and help him get through his stay. After the operation, the DSi lifted his spirits, but only temporarily. He had such difficulty coming out of the anesthesia that he couldn't even hold the stylus.

Later in the day, they ended up putting him in an incubator with a breathing tube and another IV, so they could administer antibiotics, blood pressure medication, nutrients, and sedatives (they say it's common to have to keep kids sedated, since being hooked up to all those tubes is very traumatic; considering how high-strung my son is, I don't doubt they're needed here).

That's pretty much were he is as of now — in the incubator, sedated, on medication, closely monitored. They're pretty sure it's a bacterial infection, but they don't have an exact diagnosis yet. His fever keeps spiking from time to time, but they do a culture every time and find no new growths. At least they're able to gradually reduce his blood pressure medication as that stabilizes.

In other news, I was supposed to help out an old friend tonight with some computer problems. I called to ask if we could reschedule, since I'll probably be in the hospital tonight. He of course said that would be fine. Then he asked if I had heard about a mutual friend of ours. "…What about him?" I asked. He said he was having some personal problems, and that I could google it. I thought that was kind of odd, since I didn't expect to see someone's personal problems on Google. I didn't think I knew anyone who would garner wide internet recognition. Yet when I googled his name, there came up several stories about him being investigated by the SEC, pictures of his home and "assets being seized", etc.

Not only was it a shock to hear this about him personally, but it was also a little unnerving to realize how close I was to the situation. I do some freelance computer work, and I wrote for him an account management program which basically automated some of the tasks he was doing in spreadsheets. As I'm reading these news stories, they mention account statements sent to clients with bad information, and I realize that it's my program that generated these very statements.

I don't expect any harm will come my way. The allegations against my friend have nothing to do with my program directly — my code only took the information he fed it, made calculations based on his specifications, and showed the results; and the allegations are solely based on factors outside of that. I never even received any money for my services — being too much of a perfectionist, I guess, I didn't want to bill him until I felt the product was "finished", and it seemed there was always just one more thing I didn't feel was quite right. So far, no one has contacted me to make any requests for information, but if they do, I can always provide the entire source code for the application and demonstrate that it only works to track the values it's told, not to independently audit or track investments.

It's a good thing I don't smoke, drink, or do drugs, because if I did, this would be the wrong week to try to quit.


Bandwidth for March

Nothing terribly exciting to report for March, so here are the stats: 15.78GB down, 4.07GB up, 19.84GB total.

As of the writing for this blog post, which is just after another weekend of our church's general conference (probably about 10 hours of streaming video — two 2-hour sessions on Saturday, two on Sunday, and we let it stream video for the two hours in between Sunday sessions as well instead of stopping and restarting), the "all-time total" stands at 221.05GB. Over seven total months, and I still have not reached the limit for a single month.

Of course, I don't do a lot of high-bandwidth activities. Maybe I should torrent this "Bee Ess Gee" show that everyone's been talking about for the past couple years...