Single Parent

Quite a few applications have both menu (MenuStrip control) and toolbar (ToolStrip control). Both of these controls have their menu containers. In case of MenuStrip this is ToolStripMenuItem and in case of ToolStrip we can use ToolStripSplitButton to get same effect. Both of those controls share DropDownItems property and with this you could make one ToolStripMenuItem and add it to both:

var newItem = new ToolStripMenuItem("Test");
newItem.Click += new EventHandler(newItem_Click);
toolStripMenuItem1.DropDownItems.Add(newItem);
toolStripSplitButton1.DropDownItems.Add(newItem);

This code looks nice but it does not work. In this case we will get Test added to toolStripSplitButton1 only.

Culprit for this is in SetOwner method (as seen with Reflector):

private void SetOwner(ToolStripItem item) {
    if (this.itemsCollection && (item != null)) {
        if (item.Owner != null) {
            item.Owner.Items.Remove(item);
        }
        item.SetOwner(this.owner);
        if (item.Renderer != null) {
            item.Renderer.InitializeItem(item);
        }
    }
}

As you can see, if item already has an owner, that owner is removed, and only than new owner is set.

Only solution is to create two new items and assign each to their own parent control:

var newItem1 = new ToolStripMenuItem("Test");
newItem1.Click += new EventHandler(newItem_Click);
toolStripMenuItem1.DropDownItems.Add(newItem1);

var newItem2 = new ToolStripMenuItem("Test");
newItem2.Click += new EventHandler(newItem_Click);
toolStripSplitButton1.DropDownItems.Add(newItem2);

While this means that you have two pieces of same code, you can find consolidation in fact that event handler methods can be reused.

Windows 7 on August 6Th

Illustration

Finally it is known. Earliest date you can get Windows 7 (and Windows Server 2008 R2) will be August 6th. This date is for those fortunate enough to be MSDN or TechNet subscriber.

Mere mortals will need to wait until October 22nd.

[2009-07-22: Windows 7 has reached RTM status.]

Hyper-V Drivers in Linux

Illustration

Microsoft has shared his Hyper-V integration components with Linux community. That contribution to Linux Driver Project will make it possible to have integration between any Linux and Hyper-V that was previously reserved for Suse and RedHat.

In worst-case scenario this will enable other distributions to work faster while under Hyper-V.

You can see more details on Windows Virtualization Blog.

Installing Windows XP Media Center Edition

Illustration

I do like Windows 7, but I still have few computers that for various issues (mostly driver availability) must work under Windows XP. Just to have fun, I decided to install Windows XP Media Center Edition this time.

Image of MCE is little bit bigger and it occupies two CDs. There is no DVD image so you are force to insert second one in appropriate moment. What came to me as surprise is that it requires Windows XP Professional Service Pack 2 to be inserted as third disk.

First attempt was just to cancel that dialog and that left me with unusable operating system since half of programs went missing.

For second attempt I just took Service Pack 2 from Internet and gave it to installation. It worked until next file was required and that file could not be found. That left me puzzled since that file was on CD1. I gave him CD1 and OS was installed. When I tried to apply SP3, everything just froze.

In third attempt, when asked for SP2 CD, I just returned first disk back in. I was surprised that installation didn’t mind and everything was installed perfectly. Even subsequent installation of service pack 3 went without problems.

Why did this happen? My guess is that slip-streaming is to be blamed. On original disks, everything was arranged in proper order but when service pack was slip-streamed (MCE comes with SP2), all updated files were arranged on first disk. Nobody bothered to re-arrange it and that caused need to reuse CD1. Installation itself knew only that it needs SP2 files and nobody bothered to change prompt to something more useful like “Please insert first disk again”.

ESports Heritage Classic

Illustration

For those hungry of old style Starcraft players eMooseSC is casting eSports Heritage Classic games. For all Boxer fans, it is time of joy since he is actually doing quite well (or was - I know about first games and I am hiding from results myself).

First video of tournament can be found here.

P.S. Sound is quite lousy. :(