2009-07-29

This is not the SelectedValue you're looking for

Oh, here's a fun one.

I have a list of locations that I'm retrieving from a web service, and I want to display them in a ComboBox. I also want to have a blank entry at the top of the list, so "nothing" can be selected. While I'm sure there are ways to do this with less code, creating binding objects and such (especially since the retrieved object list is already pre-sorted in the order I want), I've resorted to just creating a DataTable with an ID and display column and copying the values I want into it. It does make things easier when I have one combo box filter another, as DataTables already have code written for searching and filtering.

Anyway, after I get my data, I have a DataTable that looks like this:

LocationIdLocation
DBNull.ValueString.Empty
2Aurora
7Colorado Springs
1Denver
3Ft. Collins
4Longmont
6Parker

Now, I bind it to my ComboBox like this:

combo1.DataSource = dataTable;
combo1.DisplayMember = "Location";
combo1.ValueMember = "LocationId";

Note that you have to set the DataSource first and the DisplayMember & ValueMember properties second, otherwise you get a ComboBox full of "System.Data.DataRow". Nice.

Now, on this form, when a value is selected, the selected value is used to filter another list; and, when the form is submitted, the selected value is passed off to a web service. How do you find out when a value is selected, and what that value is? Simple; bind to the SelectedValueChanged event, and query the SelectedValue property, right? In theory.

In practice, no. To make a long story short, I dropped a label onto the form so I could see what was going on in "real time". First, the code:

private void combo1_SelectedValueChanged(object sender, EventArgs e) {
     label1.Text = Convert.ToString(combo1.SelectedValue) + " - " + Convert.ToString(((System.Data.DataRowView)(combo1.SelectedItem))["LocationId"]);
}

And the results:

ComboBox selectionLabel1.Text
empty - 
Aurora1 - 2
Colorado Springs2 - 7
Denver3 - 1
Ft. Collins4 - 3
Longmont6 - 4
Parker7 - 6

Incidentally, the SelectedText property was always blank.

On the up-side, as you can see, I found a way to get the real value (using the SelectedItem and casting appropriately). On the down-side, it means I have to use that construction to get the selected value on this and every other similar ComboBox (there are actually four on this form alone), since SelectedValue, apparently, doesn't.

2009-07-23

You have... zero... messages.

As I was attempting to pay my T-Mobile bill this past weekend (a futile endeavor, as their billing system was unavailable — an unfortunately very common occurrence), I decided to look at their offered services. It was mostly just morbid curiosity rather than actual interest, as I find cell phone rates for services obnoxious.

I've ranted about the ridiculousness of text messaging prices before. (As a side note, I have noticed that it does seem that I am not charged for a text message receipt when one is sent to me, but only when I choose to read it. It's still not terribly comforting, considering my phone has a tendency to double-tap the "OK" key, so my attempt to view my message list often inadvertently results in my reading a message, whether I wanted it or not.)

One thing that annoyed me was the fact that text messaging plans were specific to phone lines, not to plans. My wife and I have a phone plan where we share minutes; but we cannot get a plan that allows us to share messages. Well, T-Mobile has added a family messaging plan that — lo and behold — allows you to pay once for messaging on all lines on your account! Unfortunately, the only plan available for an entire family is the "unlimited" plan, which is $25/month. It's still way above and beyond expensive for our usage (which is more like 10 messages per month), but I'll bet for some families, this would be quite a deal.

Another major annoyance I had was that there was no way to block text messages. You couldn't stop someone from sending you messages to potentially run up your phone bill. Well, that, too, is no longer a problem. There are now options for blocking messages, either per-phone or for the entire plan. There are various options for blocking, too, limiting outbound messages only, or limiting inbound messages to those from other phones (i.e. no automated spammers), or blocking all inbound and outbound messages completely. And best of all, all of the options are free!

Needless to say, I turned on all message blocking. As long as they insist on charging per text-only, length-limited email message, I won't be using it.

And while this may come as a disappointment to the two people who actually send me text messages from time to time (which I don't read, and either keep forgetting I don't read them or keep forgetting to remove me from whatever distribution lists they have that I'm in), I can only say: just send me an email. Or call. That's what a phone is for. :P

2009-07-13

The $2 Electric Razor

I've used an electric razor ever since I first started shaving. They're quick, they're easy, and they're safe, especially compared to the standard blade. But where I did use a rechargeable before, I've since gone to just using a plug-in. The problem I had with rechargeables was, whether I left them plugged in all the time or ran them down and "deep cycled" them, it seemed like the batteries would consistently stop holding a charge before the blades would get dull.

The interesting thing about replacing blades, though, is that I never actually do it. I've found that the price for new blades is so expensive, and the price for a simple, plug-in electric razor is so cheap (because only the cheapest models are plug-in; the first feature that gets added as the price goes up is cordlessness), that it's just as cheap and twice as easy to buy a whole new razor than it is to find a set of blades that's compatible with the razor I already own.

Case in point: my last Norelco razor stopped cutting as well as it should. I went down to Wal-Mart to look at razors. Razor blade heads were $29 (and since I didn't know the model number of my razor off the top of my head, I wouldn't know which one to get, if a compatible set was there at all), and a new Panasonic razor was $31. Which leads to the inescapable conclusion that the razor itself — the housing, the motor, and even the flip-up trimmer and the blades contained therein — are worth a grand total of two dollars.

Which sounds about right, considering the flip-up trimmer on my old Norelco had also broken, being driven by a cheap piece of plastic. Buying new heads wouldn't fix that.

2009-07-05

Bandwidth for June

June was also a fairly light month. Total downloaded was 18.49GB, total up was 6.28GB, for a grand total of 24.77GB.

I got the Xbox 360 game Ghostbusters for Father's Day, and I was very close to activating a Netflix trial so I could stream the original movie — which would have been very educational as far as bandwidth consumption is concerned. However, that very next day, my Xbox died and had to be sent in for repairs, so that killed those plans.

2009-06-26

The importance of keeping good records

I'm a bit of a pack rat. Ok, I'm very much a pack rat. I don't like to throw anything away on the off chance that someday, I might have a need for it. It's especially bad when it comes to financial information. I have receipts dating back to the 1900s — which used to sound much more pathetic than it is, but considering they were 9½ years ago, I think we can safely upgrade that statement from "sounding pathetic" to "actually pathetic" now.

Regardless, I finally am able to reap the rewards of not throwing papers relating to money away. I got a letter from the IRS a couple weeks ago that I had been selected for an audit (What, I didn't mention that in my "pity party" post? Hmm, probably should've; it definitely qualifies) and that I needed to gather information about my charitable donations for 2007 (what fellow Geezer Gamer "SlapShotSal", who does taxes for a living, tells me is a "substantiation audit").

I knew the bulk of my donations for the year would be to my Church, so I got the statement I received from the Church for 2007, which had a list of all donation dates and amounts for the year. Then I pulled a report in Quicken for that year and found the check numbers that corresponded to those dates and amounts. With that list, I went to all my bank statements for the year and found the statements they appeared on and the dates they cleared. I figured these dates would be important to get the images of the canceled checks from my bank, since to see old checks, I usually have to select the statement they were on. This could've been a tedious process of having to download each statement from my bank, but I keep copies of my statements on my home network for easy reference. (It worked, too; it was very easy to reference all those old statements.) Yes, the pack rat trait applies to digital files as well — probably even more so.

Now that I had a list of check numbers and dates, I logged on to my bank for what I dreaded would be the most tedious part of this whole process — having to find each check on the old statements and get the images, one by one. Maybe I would take them into Paint.Net (my favorite free image editing program du jour) and stack three or four of them on a page to save paper.

I found the link to prior statements, but much to my disappointment, they only went back 18 months, the earliest one available being January 2008. So that wouldn't work. But there was another link for searching for transactions that indicated check images were available as far back as 2005. (Glad I didn't get audited for any years prior.) I entered a date range of the whole year, a check number range from the lowest to highest number I had, and selected "Check" for transaction type.

I couldn't believe what I saw. There was a list of all the checks, with a checkbox by each one. At the bottom of the list were two options, one to select Large or Small images, and one to select Front only or Front and Back, and a button marked View Images.

Actually, the search results were limited to 100, so I had to do the first half of the year and then the second half, but big whoop. There it was, exactly what I needed. Select the checks I needed to see, and hit View Images to see just those checks.

When I viewed the images, it showed me two checks at a time, with front and back images — so four images total — with some simple navigation at the bottom to move to the next pair of checks. Since the site's not in a frameset, I couldn't tell my browser to just print a single frame (i.e. the one with the images), and I didn't want to print the navigation links (or the rest of the webpage for that matter), so I figured I'd still be copying images from the screen. Just for kicks, though, I called up the Print Preview to see what would happen if I tried to print.

They thought of that, too. Apparently there's a printing stylesheet in place that turns off everything but the content, because in the Print Preview, the only thing visible were the check images. No navigation, no links, no tabs or corporate logos or anything extra.

Here I thought I'd be at this for days, or at least hours, gathering images and printing them out one by one, and all I had to do was click "Next, Print, Next, Print, Next…"

I'd love to publicly praise this bank for their extremely useful website, but at the same time I don't necessarily want to advertise to the rest of the internet where I keep my money. I did make a point of sending a message of thanks to their customer service inbox, though.

So, with that out of the way, now I can go back to playing my Xbox. Except that is currently on its way to a repair center in Texas and probably won't be back for a couple weeks.

Yeah, I guess I forgot to mention that, too.

2009-06-18

The hits just keep on coming

It's a pity party, and you're all invited.

When I picked up my son's medication as we got him out of the hospital, the total bill was close to $500 for a month's worth. I figured they were just having issues with insurance and I'd just need to resubmit the claim later. In any case, it wasn't something I could worry about or negotiate at that time — the treatment required keeping the level of medication in his blood stable, and we needed the pills then. Well, I finally got around to calling my insurance carrier to see what was up.

Here's what's up: that medication isn't covered. The price, unfortunately, is what it is.

D'oh.

A couple weeks ago, a tornado passed really close to our house. We didn't have any damage from the twister, thankfully (in fact, it did surprisingly little damage for touching down in the middle of a shopping mall, causing no injuries). However, there was golfball-sized hail. We have an insurance adjuster coming to look at our roof to inspect for hail damage on Monday. If repair work needs to be done, it's covered, just with a $1000 deductible. Which could be a lot worse, but it's an expense when I don't need any more expenses.

And, my glasses broke this morning. I got these frames that were supposed to be made of this indestructible flexible alloy, and the frames have in fact held up well. The problem is, the screw on the hinge is held in place by this flimsy piece of wire that's barely soldered on to the indestructible frame. This same hinge actually broke twice on me. The first time, it happened so quickly as to still be under warranty that I could have the frames replaced. Not so, this time.

Fortunately, my older pair is still in great shape, and my previous prescription isn't that much different, so getting a new pair is something that doesn't need to happen immediately.

And, I just got a call from my wife, who is right now taking my son (the one with the $500/month medication) to the doctor's office with sharp, stabbing pains in his stomach.

2009-06-15

Wait, what about The Social?

A year and a half ago, I looked at this "Zune Social" thing, and I wondered if it would be possible to "jump in" with just my desktop PC. Having a Zune Card that was just like my Xbox Live gamercard, with a running history of the music I listened to, sounded kind of cool. Gimmicky, sure, but cool. And the fact that I already had a Zune Card simply by virtue of having a gamercard meant the cost of entry was eliminated. (I suppose this is also related to me being a sucker for features, as I had access to this feature that I wasn't using.) But in order to use it, you had to use the Zune Media Player, which, compared to Windows Media Player, was pretty lacking.

I posted a comment in the Zune forums, suggesting it might be nice just to have a WMP plug-in that updated my Zune Card with my stats from WMP. The responses I got back were rather disparaging, saying they couldn't do everything the Zune Media Player did in a mere plug-in. It was also the prevailing opinion that the Zune Social was for Zunes, and it didn't really matter what I played on my PC. (Ok, never mind the fact that I could play things in the ZMP and have it update my Zune Card.)

Back in September, they released a software update, and I decided to give it another look. In short, nothing had changed. I came to the conclusion that the Zune Social was a Zune-only club, and I would just be anti-social until I somehow acquired a Zune of my own.

Two weeks ago was E3, and Microsoft announced that Last.fm would be coming to the Xbox 360. I hadn't really looked at Last.fm before, so I signed up. Not only does it offer streaming music, but it (to quote its home page) "recommends music, videos and concerts based on what you listen to." And how does it know what you listen to? Well, obviously it can track the songs it streams to you and the ones you flag as tracks "loved" or "blocked". But it can also track songs played in Windows Media Player using a plug-in.

So here you have this third-party service that is doing exactly what I was asking for from the Zune Card. And Microsoft is integrating that service into the Xbox 360.

Oh yeah, they did also say that the Video Marketplace on the Xbox 360 would become the Zune Marketplace. But so far, they've only announced that for videos. Not music.

I don't get it.

2009-06-10

I'll handle any key you want... except that one

Here's one of those that makes a little more sense when you think about it, but it still leaves you scratching your head until you figure out what's going on. And then you think about it some more and realize, no, it doesn't make sense at all.

When you want to capture keypresses in a control on a Windows form, the "best" place to do that is the KeyDown event. It gives you the ability to capture keys, the state of the modifier keys (Control, Alt, Shift), and to mark that keypress as being "handled" so the key does not continue on as actually being typed. It also provides access to capturing unprintable keys (like Escape or Insert).

However, one thing it does not do is let you capture the Tab key. This is because the control doesn't even get a KeyDown event when the Tab key is pressed. (Indeed, Microsoft considers it a bug when it does trigger a KeyDown.)

You can sort of rationalize this behavior when you realize that the Tab key is "special". The form uses that key to determine when to move from one control to the next. So, in that way, it would make sense for the Tab key to not even get to the control. However, you can easily debunk that rationalization with two controls: a DataGridView and a TextBox. A DataGridView, with its StandardTab property set to the default of False, will, when a Tab key is pressed, take it upon itself first to move the active cell through the grid, and only when the last cell is reached then let the form move focus to the next control. Likewise, a TextBox that has both Multiline and AcceptsTab properties set to True will take any Tab keypresses and add a tab character to the input, never passing that keypress to the form.

In any case, it seems that, for whatever reason, the Tab key is handled by the form sometime after these possible control overrides, but before the KeyDown event could get fired.

Solution? Well, it turns out, there are two.

The first one I found is to override the form's ProcessCmdKey method. Start by calling the base ProcessCmdKey method, which returns a boolean that indicates whether the key was handled. Then, check to see if this.ActiveControl is the control for which you want to trap the Tab key, and if the keyData parameter passed in to ProcessCmdKey contains the Tab key ((keyData & Keys.Tab) == Keys.Tab). If so, do whatever it is you wanted to do, and set the boolean return value to true, indicating you've processed the key yourself. At the end of the method, return the boolean. (I found a simple example here.)

The annoying part is, if you were trapping for more than just the Tab key in the control's KeyDown event, you now have your logic split in two different methods (control_KeyDown and form override ProcessCmdKey). Also, if you are doing this for multiple controls (as I was for, coincidentally, a DataGridView and a [single-line] TextBox), you have to copy and combine the logic from the other controls' separate KeyDown events into the ProcessCmdKey method, testing the ActiveControl to make sure you know which control you're in.

The advantage, however, is that you only have to test the cases you're interested in. If, for instance, you want to catch a Tab, but still allow a Shift+Tab to default to the standard form's handling, you just test for an un-shifted Tab and do your work, and let the Shift+Tab condition "fall through".

The second solution is to bind to the controls' PreviewKeyDown event. This one fires in that sweet spot before the form claims it as a "command key". The event gets the parameter PreviewKeyDownEventArgs e. If you want to handle the Tab key in the KeyDown event, just check to see if e.KeyCode == Keys.Tab, and if so, set e.IsInputKey = true.

The disadvantage to this method, however, is that now you are responsible for moving the focus as appropriate — you can't just let the handling "fall through" to the form, because it won't handle it anymore. Depending on how confident you are on the structure of your form, you can either call another control's Focus method or the form's SelectNextControl method (and don't forget to set the Handled property in KeyDown, otherwise the new control might receive the same Tab keypress as well, or it might try to type the Tab as input into the old control — either way, the results might not be pleasant).

Personally, I like the second solution better. Although there is more logic required to do what should be standard Tab handling, it means the logic for my non-standard Tab handling is in one place per control, not split across two different events.

2009-06-05

Bandwidth for May

Whoops, forgot to grab the data for the beginning of May. Daily numbers are missing, but the monthly totals are accurate.

Total for May: 19.98GB down, 4.54GB up, 24.52GB total. Not quite a tenth of the cap. This month has the second lowest total since the cap, coming in just ahead of March.

If it weren't for the impending medical bills, I'd sign up for Netflix, if only to see what it would do.

2009-06-04

A sucker for features

Yeah, so a few people have noticed that, despite my general disdain for "social networking" services as a whole, I finally got suckered in and signed up for both Twitter and Facebook.

I was a long-time user of Microsoft's MSN Messenger service. (I even had a "charter membership" to the Microsoft Network, for whatever that's worth. Remember when we didn't have "internet service providers", but signed on explicitly to companies' dial-up networks?) Anyway, eventually I got a job where their "standard" messenger client was AIM. I didn't want to have to run two distinct messenger clients because of the combined resource usage, so I looked for a client that would connect to both services in a single client. The one I selected was Trillian, which I installed and started to use.

When I got it up and running, I noticed there were little icons that lit up with each service to which it connected, and only two of its four lights were lit. I felt like I was missing something, because I was using a program but not all of its features. So I entered my credentials for my almost-forgotten ICQ account, and on came another light. What was the fourth one? Yahoo Messenger? I didn't know they had a client, and I certainly didn't know anyone on it. But I wanted that last light to light up. So I signed up for a Yahoo account, and finally my program was complete.

Now you might understand a bit what feelings went through my head when I heard about Microsoft's E3 press conference this week. Felicia Day (who has a very cute face, but dang that girl needs to eat before she blows away) announced that the Xbox 360 would be integrating with Facebook, Twitter, and Last.fm this year.

New features? On my 360? And I don't have access to use them? Well, I'd better sign up, then!

Of course, I had to be a touch creative with my account names since I waited so long, but fortunately I was able to get away with just adding a "1" to my alias and calling it good. (Except for Facebook, which demands a real name. What do you mean, "Yakko" isn't a valid first name?)

I don't know if my Facebook page will see much action (we all know how infrequently I update my own blog as it is), but I've already found that Twitter is fairly useful for those really quick thoughts I think might be nice to jot down but don't think are worth a whole blog post. (So far, I've resisted the temptation to reply to the tweets of celebrities who will never know I exist, but we'll see if I can maintain that resolve.)

And after listening to the '80s Tag station on Last.fm most of the day yesterday, I already can't wait for this to be turned on in the 360.

They hyped up Netflix again, and I started to feel tempted again. That one, though, costs money, and signing up for another entertainment service right before medical bills start rolling in sounds like a really bad plan.…

2009-05-27

The fundamental interconnectedness of all things

It seems when my son is admitted to the hospital, my laptop reveals a new problem.

Now, my HP Pavilion tx1420us is failing to power on after any kind of software shutdown state. This includes: failing to resume from sleep, failing to power on after hibernate, and failing to power on after shutting down from the menu.

Fortunately, I'm able to get around this by shutting it down with the hardware switch. When I power up the computer and notice it's not starting (the audio and wireless lights both remain orange instead of turning blue, there is no disk activity, and the screen remains dark), I can press and hold the power switch in the "off" position for a few seconds until the system shuts off, and then power it back on. Sometimes, though, I have to do this twice.

Also fortunately, I'm using the Windows 7 RC, and Windows 7 includes a feature called "hybrid sleep". The short of this is, when the system goes to sleep, it also writes the hibernation file; so even though I can't wake it up and have to force the power off and wipe out the sleep state in memory, when I power it up it is able to resume from hibernation.

This could indicate that the wireless failure was not directly a fault between the system and the Wi-Fi card, but just a symptom of a general failure.

More so, though, I see this as a failure on my part for trusting HP to produce a laptop that would last beyond its warranty period.

2009-05-26

Haven't we been here before?

I got a call while I was in a meeting today, from my wife. She's the only person I'll accept calls from when I'm in that situation, and I answer the phone in the same way, with a whispered, "Hi, I'm in a meeting, is everything ok?" Almost always, she'll say everything's fine, and just call her back when I get out.

Not today.

My son was having a really bad day today, having emotional outbursts and not fully processing what was going on or where he was. Since he's on a high-dose steroid, he's been fairly moody and irritable lately, but never to this extreme. Still, it didn't seem like anything more than just a really bad case of frustration and mood swings. My wife finally got him calmed down enough to take a nap, figuring that would do him some good (he has typically been taking a long nap in the afternoon anyway), but after maybe a half hour or so, she happened to look over at him and notice that he wasn't exactly napping — his eyes were open and twitching. She called the doctor, who then advised her to call 911. When he was on the ambulance en route to the local hospital's ER, she called me.

I excused myself from the meeting, grabbed my coat and backpack, and met her there. He was having a mild seizure. They gave him some medication to stop the seizure, and then they did a CAT scan to rule out the possibility of a stroke. The scan came up normal. Of course, I predicted as much — the entire 5-week stay in the hospital, every lab test they could think of came up negative; he just wasn't well, had ferritin levels higher than they'd ever seen, daily fevers over 104°F…

Anyway, with the seizure under control, they transferred him back up to Children's Hospital. I parked in the same parking lot and went to the front desk. I couldn't just flash my wristband and walk in this time, though; I actually had to stop and find where they brought him in. The desk clerk found that he was brought to the ER and offered to walk me there. I was about to object, since I knew the way there, but then I remembered that there is a card-access lock door from the main hospital leading to the ER, and I'd need someone to let me in anyway.

It's sad that I know this.

The primary doctor here in charge of his case was aware of this possibility. The medications he's on, the cyclosporine in combination with the steroid, can raise blood pressure, and the increase in blood pressure can trigger a seizure like this. In fact, he noted this at my son's visit last week. The day after he saw my son, my son had an appointment with the cardiologist, and the doctor said he saw today the blood pressure taken at that appointment and was very disappointed that the cardiologist didn't call him. Although the blood pressure taken wasn't extremely high, it was high enough that he could have prescribed some blood pressure medication to keep it down and prevent this seizure from being a possibility.

It's the doctor's initial opinion that, once we get his blood pressure back to normal and he recovers from the seizure, that he'll be good to go home again, just with some blood pressure meds as well this time. Unfortunately, he's also running a fever now (his first in over two weeks), so they're checking for infection (dollars to donuts they don't find one, again), and hopefully this fever is just a temporary thing that doesn't keep us from going back home tomorrow.

It's really depressing to be back here. On Sunday, we actually started to get close to normal. The whole family was finally able to attend church together. He slept through our sacrament meeting, but he attended his Sunday School classes and was smiling and laughing with his friends. He's even started to get himself up and down the stairs at home. And now… here we are again.

2009-05-24

Why didn't you do what we wouldn't let you?

So while I was in the hospital watching over my son, I signed on to CitiCards.com to pay my Master Card bill. Imagine my surprise when I see a message, saying my account information has been compromised, and for my security web access to my account has been disabled, and a new card is being sent to me.

In the meantime, fortunately, my card still worked for purchases (even online), so I wasn't completely without access to my credit. I just couldn't sign on to my account online.

Now, this did concern me a bit. After all, the reason I was signing on was because I needed to pay my bill. And this was how I paid my bill. Since I signed up for "paperless billing" — a service they provide and encourage — it was also the only way I had to pay my bill. And here they were, disabling access to my account and the means for paying my bill. But surely they wouldn't hold me responsible for not being able to do something they were keeping me from doing, right?

I finally got my replacement card. I lost count, but it was a few weeks later. So I was finally able to register my new card for online access, check my account… and see that finance charges and a late fee had already been assessed to it.

I guess CitiBank got tired of waiting for their bailout and decided to take it out on their customers.

2009-05-14

It's good to be home

After five weeks and a day, we finally took my son home from the hospital yesterday. The doctors with all their tests were able to rule out enough of the major diseases to decide it was safe for him to be at home, and all the medications and treatment he was on could be safely given at home.

Now, granted, he's still not 100% well. He's on a few different medications, and his immune system is still recovering from being sick (and some of the treatments he was on). And he still has a PICC line in his arm, since we'll be making repeated trips back to the hospital for blood tests and checkups. But just the fact that we're all home is a huge relief to all of us.

He is definitely getting better, though. As it so happens, for about the last week, he was no longer getting his daily fever spikes, and without the fevers to drag him down, his appetite and strength has been coming back. If I had to make a guess, I'd say there was an infection (secondary to the Kawasaki disease they did manage to diagnose) they couldn't find, but when they happened to give him a final dose of antibiotics as a precautionary measure while they switched medications that affected his immune system, it probably finally wiped it out and let everything else fall into place.

We did get our first taste of the medical bills, though, when we had to pick up the prescriptions. We're hoping that insurance just didn't get billed properly, but three prescriptions ended up costing us close to $500 (and we had to make a trip back to the pharmacy in the hospital, as the drugs aren't carried at any branch close to home). The cashier actually apologized as she rang it up.

One thing at a time, though. At least we're home, all under one roof, sleeping in our own beds.

2009-05-08

Name them one by one

So with all the crap hitting the fan over the past 4½ weeks, maybe it's time to stop and count my blessings.

  • My son is alive, and is getting his symptoms cared for (even if they can't cure the disease).
  • We live in the suburbs of the city that has one of the best children's hospitals available. (We've met people from as far away as Hawaii, who are staying in the Ronald McDonald house while their child gets treatment here. While we may not be spending much time at home, we can at least go home every day to get clothes, supplies, check on the pets, …)
  • I am employed full-time (not on hourly contract), at a small technology company that has been more than accommodating to my very unpredictable schedule, including my rather reduced hours (although I intend on working some this weekend to catch up on some work, they've accepted my 6- and 7-hour days without complaint). (I'm sure it helps that I'm still meeting deadlines and getting work done.)
  • My job is only a few blocks from where my kids go to school, and so it is very easy for me to pick my older son up and bring him here, where he can do his homework and play his Nintendo DSi until it's time to go. Additionally:
    • my workplace is ok with this arrangement
    • I have an office, so I have space for him to be in
  • My church has been there to provide meals for us, and to take our toddler off the hands of my wife for the day, so he's not confined to the hospital room every single day.
  • GeezerGamers.com — I've been a part of this community for a little over four years now, and the outpouring of support and prayers from these people have given me a huge morale boost I didn't realize I needed. And on top of that, they've also sent me and my son some Amazon gift cards and a care package that included a new Xbox memory card (to replace the one that "mysteriously" disappeared from the hospital room this past weekend). They've been an awesome group of friends, more than I ever expected or ever thought (or hoped, at least in this way) I'd need.

Hopefully the hospital stay is coming to an end. Although the doctors still haven't figured out The Problem for which they can prescribe The Cure, they have at least eliminated enough major issues that they're considering sending us home. He'll still be on medication (they've started switching his IV-based medicines to pill form), and as long as he shows he can eat and drink enough to sustain himself without IV supplements, if his white blood cell count recovers from one of the medicines he was on, and if nothing else major comes up, we may be taking him home next week (a "mere" 5 weeks after he was admitted).

Sure, we'd still need to bring him in for some tests rather regularly (and they may leave his PICC line in while he is coming back for tests), but even if we had to spend, say, 4 hours a day every day going back and forth to the hospital for tests, that's still 20 more hours a day he'd have at home than he has now. And that's another blessing worth counting.

2009-05-01

April in Review

April sucked.

  • Middle son ends up in the hospital for an extended stay. (Resolution: none yet, still there.)
  • Friend and client busted by SEC for running a Ponzi scheme. (Resolution: none. Have had little time to process this myself, let alone follow the case; see above.)
  • Youngest son splits head open at hospital. (Resolution: glued shut, healed fine.)
  • Snow storm kept us at home away from hospital. (Resolution: worked out; my mother had flown in for the weekend and was already there with my son.)
  • Master bathroom toilet seat split. (Resolution: none, haven't been home long enough to fix.)
  • My wife was rear-ended on the way to the hospital one morning. (Resolution: n/a, occurred at such a low speed the only "damage" done was dust in the shape of the offender's license plate that wiped away clean.)
  • My laptop's wireless card died, due to an extremely common problem with this model of HP laptop. HP wants $100 just to look at it before they'll decide what to charge me to fix it, even though they repaired the identical problem on the identical laptop (my wife's) a few months ago. (Resolution: bought a $30 USB Wi-Fi adapter.)

Yes, I know, everything worked out, and some of these are really minor things. It just seemed like everything came crashing down all at once, and especially when you're dealing with something major like having a kid in the hospital and are spending better than 12 hours a day there, it all seems like a lot.

Even when this is all over, it won't be; I have a feeling we'll be paying for this for months, if not years to come. My hospital stay for my appendix cost thousands, and that was only for a couple days.

But that's something to worry about later. Right now, the most important thing I want resolved on the list is still there. My son is still in the hospital, still not getting better to the point where he can come home. My wife and I have spent the night in the same bed precisely three nights in the past 24 (when my mother showed up for the one weekend and sent us home). And what sleep I do get during the week is definitely not quality, considering the inch and a half of foam on a sheet of flat plywood that qualifies as a fold-out bed here.

I know, things could be worse. I just want to know when they're going to get better.

Bandwidth for April

You can see the spike on the first weekend where, again, I watched the streaming video of my church's general conference broadcasts. There are two 2-hour sessions, with two hours between them, during which church news is broadcast. Although we didn't watch for six hours straight, I did let it keep streaming the video, partially because I didn't want to have to restart the stream (I put my laptop up on a high shelf when I connected it to the TV for output and didn't want to climb back up to get it), and partially to see what would happen to my bandwidth numbers. (Sunday, I actually did stop and restart the stream when I found my bluetooth mouse worked as a suitable remote control.)

Although I haven't been home to do a lot of Xbox gaming this month (spending most nights in the hospital with my son), I still use my home network connection quite a bit as my own personal proxy server. I've used this from work for over a year now, mainly to prevent any misunderstandings that might occur if I were to happen to hit the wrong website at the wrong time. I'm also using it from the hospital, since they have an unsecured wireless connection that is also a tad overzealous in filtering out websites that "might" be "unsafe".

Anyway, the total numbers: 27.06GB down, 5.32GB up, 32.38GB total. This month is the second highest, ranking behind the last general conference month (October).

2009-04-30

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.

2009-04-28

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.

2009-04-20

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() {
    base.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.