You Cannot MouseLeftButtonDown if You Have No Mouse

I’m in the middle of a fairly large scale code review and I wanted to stop and alert everyone to a common mistake I am seeing in a lot of code that I read. You should use the Click event in about 99.99% of the cases that most people are using the MouseLeftButtonDown event. The reason for this is that if you have no mouse, there is no left button, and if there is no left mouse button it cannot go down.

Imagine if I am a keyboard only user, I would tend to Tab my way though a web page to find the button or link I want to activate. I would then press either the Space Bar or the Enter key to activate it. In POSH any Hyperlink would fire using either of these methods. In Silverlight either of these two methods will activate the Click event, but it will not substitute in for a MouseLeftButtonDown event.

I think this stems from Silverlight 1 where the only way to detect a click was to listen for the MouseLeftButtonDown event, but those days are long behind us.

If your intention is to actually capture an actual mouse event, then use MouseLeftButtonDown. However, if your intention is to capture a Click, use the Click event.

Installing Windows from a Flash Drive

I did not come up with these instructions. I found them on the web, but because I’ll never be able to find them again when I need them, I thought I’d post the instructions here for my own reference.

From the command line run these commands:

  1. diskpart
  2. list disk
  3. select disk x
  4. clean
  5. create partition primary
  6. select partition 1
  7. active
  8. format fs=fat32
  9. assign
  10. exit
  11. xcopy D:\*.* /s/e/f E:\
  12. robocopy D:\ E:\ /MIR

 

There are a few assumptions made in this. The first is that the DVD drive containing your Windows boot disk is in drive D. The second assumption is that the flash drive shows up as drive E. If either of these assumptions are wrong change line 11 accordingly.

Beyond that look at lines 2 and 3. Line 2 will list out all the disks in your system each with their own disk number starting with 0. Look through that list and find the number associated with your flash drive. Then in step 3 replace the “x” with the number associated with your flash drive.

Because I haven’t tested this out yet line 11 is still an xcopy. My personal preference would be to use robocopy and when I try this out I’ll use robocopy. That command will change line 11 to this:

robocopy D:\ E:\ /MIR

Again, I’ll try this out and report in this entry if it works or not.

UPDATE: I was reviewing the xcopy command and the options are a little strange. /s includes all subdirectories except empty ones, and /e includes all subfolders including empty ones. It doesn’t make sense to include both options. Also /f displays the full name of each file as it’s copied. This may or may not be needed/desired. I’m currently testing the robocopy version and there doesn’t seem to be any problems.

UPDATE 2: I was successful in using robocopy instead of xcopy. Step 11 above has been changed. All in all the install took 10 minutes! Now I need to try this on a netbook.

UPDATE 3: Here’s the link to the original post describing how to do this: http://kurtsh.spaces.live.com/blog/cns!DA410C7F7E038D!1665.entry?wa=wsignin1.0&sa=50757250

what I cannot create, I do not understand

Jeff Atwood blogged about a problem he is having with HTML sanitization on Stack Overflow. The argument that Dare Obasanjo and Jon Galloway were trying to make to Jeff is that it doesn’t make sense to re-invent the wheel. People have solved this problem before and their code is available for re-use. Jeff’s argument is that he’s a professional developer and he should be able to solve this problem. He punctuates his argument with a quote from Richard Feynman, “what I cannot create, I do not understand.”

This is a fine argument if Jeff were a Nobel Prize winning Physicist working on the fundamental building blocks of the Universe. However, and I’m sad to report this, he isn’t. Software Development is not science. Some of us may use the scientific process for finding and fixing bugs, but at its heart software development is an engineering profession. What that means is that most of the hard problems have been solved before. Although it is important to understand how the solution works, it isn’t necessary to re-invent the wheel.

For example, given the inspiration and the need I could rewrite jQuery, but I don’t. Why? Because someone else who does have the time and inspiration already did it. More importantly, many thousands of people have already used it and reported enough bugs on it to make that library very stable and robust. The important part of this example though is that at any time I can, and have, opened it up and read through the code to make sure that it makes sense to me. I’m not proposing that Jeff use someone else’s HTML scrubber blindly, I’m saying he should use someone else’s HTML scrubber after reviewing it for himself to ensure that it meets his quality bar.

I also chose jQuery for this example because Jeff uses it extensively on Stack Overflow. He did not go out and write his own. In fact Jeff also uses the ASP.NET MVC framework, the ASP.NET framework, and the .NET Framework. All of these are software that he could have written given enough time and inspiration. At some point it comes down to ego. An HTML scrubber is a simple enough thing that he should be able to write it, but he really shouldn’t.

Hyper-V Integration Components… Oops

We are going to rack this up to experience. I was trying to figure out today if I have the Hyper-V Integration Components beta installed, the ones that came with Windows Server 2008 RTM, or if I’d upgraded to the RTM version of these components. Well dummy me, I double clicked on the entry in Add/Remove programs and what I got was the system removed the components lick-it-y split and told me to reboot. What, no confirmation?

In other news, after the reboot the virtual machine Blue-Screened and when I repaired it I got a Windows Activation found an “unauthorized change” and it now needs to be reactivated. Activation on Hyper-V sucks ass. If you are working with virtual machines on Hyper-V be warned that monkey-ing with the Integration Components will force you to activate again.

This is double bad because now I have to activate to use the machine, then I’ll re-install the Integration Components (I need network connection man) and then this weekend I was planning on upgrading my Hyper-V server to the new Windows Hyper-V Server 2008 OS that is free from Microsoft. I’m planning that because I am currently running the RTM of Windows Server 2008 that came with the beta of Hyper-V. I want full RTM software running over there. So what does that mean? Well, as of right now this is what I’m looking at doing:

  1. Activate Windows
  2. Install Beta Integration Components
  3. Activate Windows
  4. Use the VM until I am ready to get rid of beta
  5. Remove Beta Integration Components
  6. Activate Windows
  7. Install RTM Integration Components
  8. Activate Windows

With my MSDN licensing on Windows Server 2008 I’ll use 4 of my 10 activations on this one server alone. That sucks. I guarantee I’ll have to call the activation center before Monday.

Update: Turns out I’m hosed. I need to install integration components to use the network. I have to log in to install integration components. I have to activate to log in. I need network connection to activate.

Server Unleashed Gets Upgraded with Hyper-V

I’ve been so busy lately trying to get the SQL Server Energy site out in about 15 languages that I forgot to post that last night I updated the Server Unleashed site with the new Hyper-V goodies. Of course it doesn’t talk about my favorite new product, Windows Hyper-V Server, but it’s a pretty good site, and one that has withstood the test of time so far.

The code base I thought is pretty over-engineered. I keep meaning to write a post on my experience using the MVP pattern in Silverlight but you know how blogging priority goes down when you are busy. Adding in the code for Hyper-V was fairly straight forward. The most difficult part is that the four main pillars used to be on the main navigation screen, now they are hidden behind an "Innovations” button hover state.

I’d like to thank Ben “Virtual PC Guy” for blogging about it as that reminded me to post something here about the update.

First Full SilverSpine Implementation

Today we soft launched the first site that is using the full implementation of SilverSpine. The SQL Server Energy site has gone live. Over the next couple of weeks we will be launching this same site in 15 languages all using the same exact codebase, but the content back (the SilverSpine) will have translated code. This is truly an exciting time.

The site will look similar if you have Silverlight 2 (beta 2) installed or if you don’t have Silverlight at all. We are working on the Silverlight 2 RTW version but for obvious reasons (Silverlight 2 RTW hasn’t been released yet) we didn’t go live with that.

This was a tremendous effort from a lot of people, but we’d like to call special attention to MSCOM for doing their best to stop the launch. We won, you lost. ;-)

Check it out here: SQL Server Energy

Silverlight 2 Beta 2: Should I Stay or Should I Go?

RTW for Silverlight is still off in the near future. The RC0 build of Silverlight is mainly for developers, but you have a very important web site launching in 22 languages over the next couple of weeks. The ad campaign can’t wait for the RTW of Silverlight 2. What on Earth are you to do?

Well as I see it you really have a few options.

0) Wait for RTW to switch to a newer build. This is option 0 because it isn’t really an option. You really do need to be out there testing your beta 2 applications on RC0 to ensure that you get all the updates cleaned up. This way when RTW is launched you just “flip the switch” and you have gotten rid of all of those nasty pre-release bits once and for all.

1) Leave beta 2 on your main development machine and setup the RC0 bits on a separate virtual machine or computer. For me I have the RC0 bits on my laptop and the beta 2 bits on my main development machine, but a virtual machine would work just as well.

2) Switch back and forth between beta 2 and RC0 by using the tried and true “Add/Remove Programs” control panel applet. If you go with this option you need to remove several things. I think Vista shines here because you can use the search box to help find these components. First search for “Silverlight” and you should find three things to remove: “Silverlight 2 SDK”, “Silverlight Tools Visual Studio 2008 SP1 - ENU” and “Silverlight”. Then you should search for and remove the pre-release version of Blend (that’s Blend 2.5 if you have the Beta 2 bits installed and Blend 2 SP1 if you have the RC0 bits installed).

The last step of option 2 is the difficult one. When you install the Silverlight Chainer it also installs a patch to Visual Studio. To find this in the Add Remove Programs control panel applet show updates if you are in XP or click on View Installed Updates if you are in Vista. Then look for (or search in Vista) the update with the KB#: KB956453 and remove that. Then you are clean and ready for a reinstall of which ever version you need at that moment.

Personally I think this is a lot of work. That’s why I’m glad that I have plenty of virtual machines and extra hardware that I can have several machines running different bits of stuff.

Oh, one last thing I should point out. Until Silverlight 2 ships, any site created with Silverlight 2 Beta 2 will fail to run with Silverlight 2 RC0 installed. The SilverSpine sites I’ve created all have a very rich HTML site to fall back on so I just disable Silverlight and I can surf the web without worrying about the Silverlight 2 RC0 incompatibility with Silverlight 2 Beta 2.

Silverlight 2 RC0 is Now Live!

A year and a half ago we got a taste of a new technology. This was a technology designed to leverage developers knowledge of .NET on the client side browser. Some call it Microsoft’s answer to Flash, but mostly everyone just calls it Silverlight.

Today we’ve reached a milestone in this long and sometimes rocky road to having a small .NET CLR running cross platform in the browser. Today, Silverlight 2 RC0 went live. I won’t spoil the moment with any more of my crap. I’ll just post a  few important links:

However, I need to plug a Silverlight 1.0 site that is near and dear to my heart: Windows Server 2008 The Server Unleashed 

You may wonder why I’m linking to a Silverlight 1.0 site in a blog entry about Silverlight 2 RC0, well that’s because I wanted to show you that I didn’t make any code changes at all and this Silverlight 1.0 site works perfectly in Silverlight 2 RC0. Way to go to the testers working on backward compatibility. You deserve a raise.

It must be nice to be an MVP (or how I stopped worrying and learned to love Vista)

A couple weeks ago a Microsoft MVP screamed at the top of his blog that he’d give Vista 2 more weeks and then he’d leave for the murky waters of XP forever. Well some folks at Microsoft jumped onto the case and figured out the problem. I have co-workers and friends and acquaintances and people that I probably won’t ever talk to again tell me that they hate Vista so much that they’ll never use it. In some cases they never used it to begin with, but that’s a different tale. This guy rants about a sidebar app that he installed on his computer and developers jump on the case to solve the problem. I guess at the end of the day Vista doesn’t suck as long as you know people at Microsoft to help you make it work. Too bad all those other people out there will never gain the knowledge to make Vista work.

As for the second part of his rant, he states that Windows 7 will suck simply because it is built on the same core code that Vista is built on. That tells me that he really hasn’t given Vista much of a chance. Sure, the sidebar sucks up system resources like nobody’s business, and Aero Glass also takes more than its fair share of system resources. There isn’t anything that says you have to leave them running. My wife got a new Dell computer at work the other day. She was happy that it has Office 2007 on it, but she didn’t like how slow it was. She brought it home and I turned off the sidebar and changed the system theme to Windows Classic. That computer now screams! She even said it’s faster than her old computer, but I think that’s just because she hasn’t installed iTunes yet.

What’s the point, well the point is that the Vista core is really good. If you are contemplating a new computer you really should get Vista, but unless you have 8GB RAM and the best video card out there, I wouldn’t turn on all the goodness. Based on what I’ve seen in Vista, and remember I’ve been using Vista a lot longer than 95% of you out there, it is a killer Operating System. Windows 7 is going to kick ass based solely on what I know Vista can do. Then again, I haven’t even tried Windows 7 yet, but I’m betting I’ll have a copy in my grubby little hands in October. I’ll let you know more then.

In the meantime, don’t believe the Apple hype. Vista is a really good operating system.

Now Loading… a Public Service Announcement

image This is a web page. The browser says that it is done. There’s nothing obvious going on with the screen and for all that I know the page just won’t render. However, if you look really closely at the top left, in browser default font there is a number that is counting up. Eventually it reaches 100 and the site finally appears, but considering I have a truly blazing Internet connection I don’t usually expect to wait 30 seconds to see anything on a site. The thing I really dislike about Flash and Silverlight sites is the loading time. I’m guilty of it too as I had to put a “Now Loading” screen in Server Unleashed, but I at least gave the user something to let them know the page is actually loading. This example of a loading screen is unacceptable from P.F. Changs. All of you web developers and designers out there, please remember that if your site is going to take more than 5 seconds to load even on a really fast Internet connection, let the user know that something is going on.