Wednesday, September 13, 2006

Mopping Janet

That's my band's name. I'll post the story behind the name one of these days. Suffice it to say it involved alcohol and a blonde.

For the past few months Chefdino and I have been putting together a band. The primary goal is to create original music. We went through Craig's list here in Raleigh to put it together.

I hadn't really started a band from scratch in years. What an ordeal...

My wife turned 40

I suppose I shouldn't post a woman's age. Whoops. I did it anyhow. Heh.

She turned 40 last Thursday. I wanted this birthday to be memorable in a fun way. So no serious gifts! That's not to say she didn't get some cool stuff, just no jewelry or appliances or anything that is overly typical for a birthday. I mostly went with a theme of getting her stuff she enjoyed growing up. So here's a run down of the goodies:

  • The kids each painted her a picture and I framed them - Nicholas did the family and Danny did a beach scene - very cool stuff!
  • Then the kids painted her a wooden stool - basically a really nice barstool type chair - she can use this in her own crafts work area. It's very colorful. Our kids rock!
  • Melissa was really into the pogo stick as a kid. She'd bounce up and down the stairs and all around the neighborhood. So I got her the FLYBAR 1200! This thing is a serious piece of hardware. It can go up to six feet in the air! Oh hell yes, this thing is cool!
  • She also really got into the hula hoop. In fact, she one the hula hoop contest at a large family affair a couple years ago. She smoked everyone. So naturally I got her several hula hoops. As it turns out I should have bought those online because they were sold out everywhere around here - I had to go to 8 stores to find them.
  • I got her a talking ALF doll. If you don't remember the show ALF then this will mean nothing to you. If you remember the show, you are probably already giggling. It's pretty funny. Our smaller dog wants to tear ALF to shreds. I think he gets pissed that ALF is always saying "here, kitty, kitty".
  • Then there were a bunch of things like a paddle ball set, kaleidoscope, etc.

The day before her birthday the kids were so excited about the gifts that we gave them to her a day early - LOL.

We had a party on Saturday. It was a great crowd and a great time. It's really kickass to be surrounded by great people.

Oh, in keeping with the theme of things I had bought a ton of candy from our childhood era. You can get anything on the Internet. Stuff like wax lips, pixie stix, Zotz, Charms, bottle caps, those wax bottles with colored sugar water in them, etc. All the kids at the party went nuts with this stuff. It started off as a pretty big box full of candy. I couldn't believe how much those little monsters ate! I was lucky to get some Zotz!

Melissa had treater herself to a new outfit for the party. She looked great. Really great.

She had a blast. We had friends and family from out of town as well as some of the excellent folks we've come to know since we've moved to NC.

Wednesday, September 06, 2006

Queensryche

My wife and I drove down to Myrtle Beach on Sunday to catch Queensryche at the House of Blues. It was an "evening with" so no opening band - that was a good thing in this case because Queensryche kicked ass. Geoff Tate brought it. He sounded even better than last year (which I thought was great too). The band was really tight. The guitars sounded great. They played both Mindcrime albums (I think in there entirety). And they topped the night off with a nice encore of several of their other classic tunes. All told they played for about 2.5 hrs or so. Very impressive show.

The House of Blues is not that big of a venue but it was PACKED. The crowd reaction sounded like an arena - the crowd was LOUD. There were a couple drunk a**holes near us that kept spilling drinks and bumping into us - so I farted. Oh, and after the last tune Scott Rockenfield tossed a couple sticks out and of course people went diving for them and came up throwing punches - Scott just shook his head in disbelief and walked out. What kind of moron throws down for a pair of drum sticks?

Sunday, May 14, 2006

Mother's Day

We had a full house today. My wife Melissa of course, our sons, my mom, Kat, Dino and their daughter Kayla, and Melissa's high school friend Karen with her daughter Laura. Everyone came over for lunch. I was popular with the ladies because I got them all flowers and cookies. My wife made a huge pot of my favorite soup and we broke some fresh french bread. Mom showed up with her killer orange pound cake.

Melissa spent a lot of time making the soup - a delicious ham and bean soup with her own personal touches. I love it.

After she got the beans soaking last night, started the stock, and everyone else went to bed (Karen and Laura were here for the weekend), Melissa came down and helped me untangle cables in the jam room. There were a LOT of cables and she was really helpful. It made a pretty tedious task fun because we got to just enjoy each other's company.

This morning Melissa got the soup going and it cooked for hours. Yum. It was GOOD. Real GOOD.

Ideally I would have been more helpful but I kept fading out today - I've had severe throat problems for a couple days and it really kicked my butt today.

The kids made some very cool cards/drawings for Melissa and were pretty darn good today.

It was a great day for me - Melissa I hope it was for you too.

HippieSound Inaugural Jam

No fanfare. No hype. We just kicked around some ideas for tunes today.

Dino was over today with his wife and daughter celebrating Mother's Day (hope y'all had a good one by the way). We snuck off down to the basement for a while and just fooled around with some bits and pieces of stuff for some songs. We're both a bit rusty but who cares - it was fun!

I just plugged my nylon string Godin guitar into the PA and started noodling song ideas. Later I busted out the Taylor T5 and noodled some more. Given a lull of any kind I tend to just move on to something else so we were all over the map.

It's been funny to discover that despite a lot of common musical ground and our close ages that we really don't know many songs in common. It's just as well, I want to do original music anyhow.

Thursday, May 11, 2006

Tuesday, May 02, 2006

Floyd Rose V24 Arrow Arrives!

As I mentioned back in January, I ordered a Floyd Rose V24 Arrow. I opted for a Korina one so I had to wait. The first one came soon but the wood grain looked like someone soiled a bed. I'm not kidding. Brian at Chuck Levin's basically said "dude, you don't want this - let me get you a different one". It was bad so I waited. Well it arrived about a week ago. It's smokin'! The guitar plays and sounds fantastic and just looks amazing.

More pics are available here.

HippieSound Studios Done!

Ok, the construction has been done a while. I've just been a slacker and haven't posted to my blog in a while. The construction was wrapped up around April 12th. Since then I've done some additional painting and touchups and have slowly been moving gear into the rooms. Anyhow, here are some pics of the completed room back on the 12th or so. A lot more pics are available here: http://www.hippietim.com/Studio/Studio.htm






Wednesday, April 12, 2006

The Man Who Sold The World

YouTube has everything. This is my favorite performance on any of the music contest shows ever. Heck, this is one of my favorite performances by anyone ever. I am very much looking forward to Jordis Unga's CD later this year. Enjoy! If you go to her web site you can hear a short clip of a song from her new disc. It sounds great!

Friday, April 07, 2006

Bush joke

So Cheney goes into Bush's office and says "Mr. President, there was a car bomb and 300 Brazillians died".

Bush says "how many people are in a brazillian?"

Workflow for Team Foundation?

We have a number of scenarios we'd like to enable in future releases of Visual Studio Team Foundation that would really benefit being part of a generalized workflow framework.  Things like code review/checkin processes, build release and staging, etc.  And no matter how many scenarios you cover, customers will always come up with more.  Building workflow into a system can be hard enough without having to make it extensible too.  Fortunately, Microsoft is working on the Windows Workflow Foundation as part of WinFX.  This looks very promising.  One of the folks on the team, Mark Schmidt, has written an authoring tool that looks interesting.


A company I worked for many years ago developed a huge workflow system for OS/2 and Unix so I've always been intrigued by this stuff.  It was ginormous and had all sorts of memory limits, usability was poor (it used lots of non-modal windows - and I mean lots), and everything was so darned generic that as a user you really had too much of the implementation exposed to you.  The problem is that it was a generalized engine that wasn't really a proper API that had a GUI slapped on top of it.  When what you really want is an engine that manages the flows and allows you to build a tailored customer experience that is relevant for your scenarios.


Stay tuned...

Musical Journey Part 7

My senior year in high school was a blast musically. The band with Eric, Steve, and Mike D. continued. We took on Chris Vernon as a singer. He was not the most versatile singer but he was good to jam with and a truly great guy. He was one of the funnest people I've ever been around. We continued playing Sabbath, Priest, Trower, The Cars, Pat Benatar, etc. We played keg parties and hung around with each other a lot. This was a great time really.

Then it came time to play the high school talent show. Lots of obstacles here. First, I was in trouble for some reason or another and was on restriction of some sort. Eric pleaded the case to my dad that it was not fair to the rest of the band to miss the opportunity so my folks relented and I could play the show. Then the talent show committee (or whatever it was) said Mike D. couldn't play in the band because he didn't go to our high school. So I filled in on bass - it sucked because we couldn't play the more interesting tunes we had planned on. Also, I didn't know the bass parts for the tunes we did play beforehand so I had a quick crash course on the tunes. We pulled it off and basically rocked the house. Of course we lost to some girl that did a really boring Asian dance. What a bunch of BS!!! Still, the talent show led to us getting to play a couple more keg parties.

Wednesday, March 29, 2006

How to get the active Team Foundation Server and Project from an Add-In

Ed Hintz posted "How to Write a Team Foundation Version Control Add-in for Visual Studio" which is a great guide to writing an add-in to integrate with Team Foundation version control. I won't repeat that info her. If you want to do something that is related to the active Team Server and/or Project from within a VS Add-In or VSIP package then read on.

First make sure you have a reference to Microsoft.VisualStudio.TeamFoundation - either follow Ed's steps to add them via the REG.EXE commands for convenience or load them using the Browse tab on the Add Reference dialog - in a default installation the assembly will be in "%programfiles%\Microsoft Visual Studio 8\Common7\IDE\PrivateAssemblies".

Next add a using clause:

using Microsoft.VisualStudio.TeamFoundation;

Create a member variable in your Connect class for the TeamFoundationServerExt object:

private TeamFoundationServerExt _tfsExt;

In your OnConnection method, initialize the _tfsExt object:

_tfsExt = _applicationObject.GetObject("Microsoft.VisualStudio.TeamFoundation.
TeamFoundationServerExt") as TeamFoundationServerExt;

The TeamFoundationServerExt object exposes two things:

  1. ActiveProjectContext - a property of type ProjectContextExt which contains the active server and project
  2. ProjectContextChanged - an event which is fired when the current project and/or server is changed

public sealed class ProjectContextExt
{
public string DomainName { get; }
public string DomainUri { get; }
public string ProjectName { get; }
public string ProjectUri { get; }
}

DomainName is the display name of the current server and DomainUri is the actual URI of the current server. And ProjectName is the display name of the current server and ProjectUri is the Team Project URI. Note that these values can be null if there is no active server or project.

Your ProjectContextChanged handler should look like this:

void _tfsExt_ProjectContextChanged(object sender, EventArgs e)
{
}

Within your handler you requery the ActiveProjectContext property of the TeamFoundationServerExt object.

Will Code For Food

This article originally appeared in the Wall Street Journal several years ago.  It's come up from time to time at work and most folks find it to be an amusing tale so I figured I'd post this before I lose track of it.



In these dark days of dot-com despair, Web developer Brian Yangas never thought a practical joke would yield three job leads in an hour.
 
Recently Patrick Husting, eHome Inc.'s chief technology officer and co-founder, told Mr. Yangas and 30 of his co-workers at the company's Bellevue, Wash., tech office that the online real-estate brokerage would shut all of its 11 regional sales offices and lay off the employees there.


Only the tech office would remain open while eHome tried to sell its technology. But the company might run out of money, so Mr. Husting suggested the employees be prepared and start looking for other work.


Mr. Yangas, a self-described "quirky guy," didn't fix up his resume; he fixed up a cardboard sign. It read "Web Developer...dot-com went bust...will code for food (or options)...hungry -- sober."


He arrived at work at 8:30 the next morning, bundled against the November chill in a hardy brown twill jacket and baseball cap. Sign in hand, he strolled out to the nearby highway-exit ramp and waited to make his co-workers laugh as they arrived. Mr. Yangas, 31, hoped his joke would "relieve the anxiety," he says. "You know, lighten the mood."


For the first 10 minutes, passing drivers essentially ignored the avid foosball player. Then some of the commuters, most of whom he didn't recognize, "started to notice and laugh, so I thought I'd stay a bit longer," he says.


A man driving "maybe a Toyota" shouted "Cogenix is hiring!" Mr. Yangas recalls. Cogenix is a database-application and Web site maker based in nearby Redmond, Wash. About five minutes later, Cami Cole, an associate with information-technology recruiter Maxim Group, stopped and asked "Are you really a Web developer?" Mr. Yangas nodded, and Ms. Cole handed him a business card with the parting words, "I can get you a job."


After about 45 minutes, Mr. Yangas went inside to warm up. He came back out at 10am because his boss wanted a picture of the prank. While Mr. Yangas was waiting for Mr. Husting to find a camera, "a long-haired guy in a blue truck" yelled, "Go to Microsoft campus building D. Ask for Tim."


"I wasn't sure what to think about it at first," Mr. Yangas remembers, "but later that day, no one was doing any work," so he headed down to the Microsoft campus. "I thought, it's been a weird day so far; let's see what fate brings."


He found the D building on Microsoft's Red West campus. It was three or four stories high and Mr. Yangas, who had caught only a fleeting glimpse of his contact, worried he wouldn't find the right Tim.


But he did. With the help of a new receptionist who didn't know a soul in the building but did have access to a photo database of employees, Mr. Yangas located what he thought might be the right extension.


The receptionist called: "There's this guy down here who said you yelled to him on the street." Tim Noonan, a development manager for Microsoft's MSN Explorer group, came down to meet Mr. Yangas, took him back to his office and talked to him for 15 to 20 minutes before passing him on to other members of Mr. Noonan's team.


"We're always looking for good developers, so why not" talk with Mr. Yangas, Mr. Noonan says. "And if he's as good a developer as he is at coming up with this scheme then woo-hoo! We value creativity."


Mr. Yangas "was pretty excited" about the outcome: Mr. Noonan called him back for a second, formal interview a few weeks later. And yet another rolled around a week later. Among other things, he was asked to write code on a dry-erase board and was interviewed during lunch to see if he could answer tough questions while eating. The interview lasted nine hours.


Thursday brought good news. A human-resources representative called to say the company would be making him a job offer early in the new year, once "the numbers guy comes back from vacation."


Meanwhile, eHome hasn't shut down. Since the pre-Thanksgiving meeting, Mr. Yangas's current employer has decided to reposition itself as a technology company. EHome's Web site is up and running, the company is referring leads to former agents and receiving referral fees.


So Mr. Yangas, who has two kids and is paying off a home mortgage and a minivan, says he hasn't "gone back out" with his sign. He was encouraged by the job leads, he says, but, in fact, "I was actually kind of hoping for money."

Tuesday, March 28, 2006

The best thing you can get for your iPod

The Bose SoundDock. Really. It is way cool. It is way expensive too but given the simplicity, elegance, and sound quality it is well worth it. Too many iPod docking units have subwoofers, separate speakers, lots of switches, look clunky, etc.

When I told my wife I was going to put a stereo in our living room that she had meticulously decorated she gave me a very skeptical look. Then I brought the SoundDock home and she liked it pretty much from the get go - "you mean I just plug my iPod in and that's it?" Yep. And it charges the iPod as well so I/she can just grab it and go. Since we got it we've had a lot of guests and pretty much everyone is amazed at the sound produced by that little gizmo. I'm sure we've inspired a few iPod and Bose purchases. The downside is that the SoundDock isn't very versatile - it just works with the iPod and that's it.

HippieSound Studios Construction Week 6

Last week was a slow week for progress. My contractor was called away on an emergency job for the better part of the week. But he did get the bulk of the grid ceiling up - I know this is a bear because the ceiling is filled with regular insulation, then mineral fiber insulation, then really heavy duty suspended ceiling wire with 4x the number of supports because this is a HEAVY ceiling being 5/8" thick drywall tiles with mass load vinyl overlayment.



This he helped me level the floor. I started to do it myself. This shit was supposed to be self leveling concrete. Um. Yeah. You level it yourSELF. Fuckers. I've done a bunch of construction work but have never used a trowel in my life. I didn't screw it up though because when he came over and helped me out we knocked it out pretty quick.

Flashing Dialogboxes

This example demonstrates how to flash a dialog in the taskbar after performing a long running operation from the command line.  A good example of how this is useful is in the VS Team Foundation version control toolset.  Naturally, it includes a command line utility (TF.EXE) to perform source control operations.  Sometimes these operations can be very lengthy and in the end result in a dialog box popping up - performing a lengthy GET operation that results in conflicts to resolve is a good example of when this would happen.


Our own UI framework does quite a bit more than this - this is just a scaled down example of what happens when a dialog is invoked from the command line.  Many of our dialogs end up getting displayed in Visual Studio, standalone Windows apps, Excel, the command line, etc.  So in our framework the method to show a modal dialog is actually virtual so the appropriate thing happens in each environment.


 using System;
 using System.Diagnostics;
 using System.Text;
 using System.Windows.Forms;
 using System.Runtime.InteropServices;
 using System.Threading;
  
 namespace ConsoleFlasher
 {
     class Program
     {
         static void Main(string[] args)
         {
             Thread.Sleep(5000); //  Lengthy operation...
             using (MyForm form = new MyForm())
             {
                 UIHost.ShowModalDialog(form);
             }
         }
     }
  
     static class UIHost
     {
         static public DialogResult ShowModalDialog(Form form)
         {
             return ShowModalDialog(form, null);
         }
  
         //********************************************************************************************
         /// <summary>
         /// Display a modal dialog a windows application.
         /// </summary>
         /// <param name="form">The form to display.</param>
         /// <param name="parent">The parent window for window stack ordering.</param>
         //********************************************************************************************
         static public DialogResult ShowModalDialog(Form form, IWin32Window parent)
         {
             bool isTopLevel = parent == null;
  
             form.ShowInTaskbar = isTopLevel;
             form.MinimizeBox = isTopLevel;
             form.ShowIcon = isTopLevel;
  
             if (isTopLevel)
             {
                 //  Attach an event handler so maybe we'll flash the title in the taskbar
                 form.Activated += new EventHandler(OnModalDialogFormActivate);
  
                 //  This is where you would also set your app icon on the dialog as well.
             }
        
             DialogResult result = form.ShowDialog(parent);
        
             if (isTopLevel)
             {
                 form.Activated -= new EventHandler(OnModalDialogFormActivate);
             }
        
             return result;
         }
  
         //********************************************************************************************
         /// <summary>
         /// On form activate for a modal dialog for the console.  We check to see if we are the
         /// foreground window and flash the taskbar if we aren't.
         /// </summary>
         /// <param name="sender">Form to activate</param>
         /// <param name="e">Standard event args</param>
         //********************************************************************************************
         static private void OnModalDialogFormActivate(object sender, EventArgs e)
         {
             Form form = sender as Form;
  
             if (form != null)
             {
                 Debug.Assert(form.Visible, "Form should already be visible for FormActivate");
  
                 IntPtr foregroundHwnd = NativeMethods.GetForegroundWindow();
  
                 //  First see if we're in the foreground
  
                 if (foregroundHwnd != form.Handle)
                 {
                     IntPtr consoleHwnd = NativeMethods.GetConsoleWindow();
  
                     //  We're not in the foreground so let's see if our console is.
  
                     if (foregroundHwnd != consoleHwnd)
                     {
                         //  We're not in the foreground and neither is our console window so let's
                         //  flash the user.
                         int flashCount = 1;
  
                         //  make sure we read the count from the system and respect this for accessibility
                         NativeMethods.SystemParametersInfo(NativeMethods.SPI_GETFOREGROUNDFLASHCOUNT, 0, ref flashCount, 0);
  
                         NativeMethods.FLASHWINFO fwi = new NativeMethods.FLASHWINFO();
  
                         fwi.cbSize = (UInt32)Marshal.SizeOf(typeof(NativeMethods.FLASHWINFO));
                         fwi.dwFlags = NativeMethods.FLASHW_ALL;
                         fwi.dwTimeout = 0;      //  This will get the system default which is the caret blink rate
                         fwi.uCount = (UInt32)flashCount;
                         fwi.hwnd = form.Handle;
  
                         //  blinky, blinky, blinky
                         NativeMethods.FlashWindowEx(ref fwi);
                     }
                     else
                     {
                         //  Our console has the input focus so let's be a bit more agressive...
                         NativeMethods.SetForegroundWindow(new HandleRef(form, form.Handle));
                     }
                 }
  
                 //  Don't call us again...
                 form.Activated -= new EventHandler(OnModalDialogFormActivate);
             }
             else
             {
                 Debug.Fail("Invalid sender in OnModalDialogFormLoad");
             }
         }
  
     }
  
     static class NativeMethods
     {
         public const int SPI_GETFOREGROUNDFLASHCOUNT = 0x2004;
  
         public const int FLASHW_STOP = 0;
         public const int FLASHW_CAPTION = 0x00000001;
         public const int FLASHW_TRAY = 0x00000002;
         public const int FLASHW_ALL = (FLASHW_CAPTION | FLASHW_TRAY);
         public const int FLASHW_TIMER = 0x00000004;
         public const int FLASHW_TIMERNOFG = 0x0000000C;
  
         [StructLayout(LayoutKind.Sequential)]
         internal struct FLASHWINFO
         {
             public UInt32 cbSize;
             public IntPtr hwnd;
             public UInt32 dwFlags;
             public UInt32 uCount;
             public UInt32 dwTimeout;
         }
  
         [DllImport("user32", SetLastError = true, CharSet = CharSet.Auto, BestFitMapping = false)]
         public extern static int FlashWindowEx(ref FLASHWINFO fwi);
  
         [DllImport("user32", CharSet = CharSet.Auto)]
         public static extern bool SystemParametersInfo(int nAction, int nParam, ref int value, int ignore);
  
         [DllImport("user32", SetLastError = true, CharSet = CharSet.Auto, BestFitMapping = false)]
         internal static extern IntPtr SetForegroundWindow(HandleRef hwnd);
  
         [DllImport("user32", SetLastError = true, CharSet = CharSet.Auto, BestFitMapping = false)]
         internal static extern IntPtr GetForegroundWindow();
  
         [DllImport("kernel32", SetLastError = true, CharSet = CharSet.Auto, BestFitMapping = false)]
         internal static extern IntPtr GetConsoleWindow(); 
     }
 }

Monday, March 27, 2006

Robin Trower is touring the US again!!!

I'm a huge Robin Trower fan but haven't seen him live in many years mostly because he hasn't toured the US in many years and when he was touring he didn't come near where I was living.  I was about to book a flight to England just to see him again so I went to check the tour schedule this weekend and saw that he's added US tour dates this year.  I am beyond excited.  I will try and catch at least 2 or 3 shows.

Overcoming a .NET ListView CheckBoxes quirk

In the Visual Studio Team Foundation version control UI, we display your pending changes in a ListView control.  That ListView has CheckeBoxes set to true as we allow you to perform a variety of operations on the checked items. 


At the same time we want you to be able to double click on an item in the list and have the file open in the editor. 


Unfortunately, the .NET ListView component automatically toggles the checked state of items when you double click on them.  I know that this is not the behavior of the underlying Win32 ListView control so it has to be something in the WinForms code.


At this point it's worth examing how this all works.  In a traditional C/C++ application, the ListView control sends WM_NOTIFY messages to the window that is the parent of the ListView.  This is typically a dialog box window.  In WinForms, events are exposed directly from the controls themselves.  So internally WinForms will take the WM_NOTIFY message and reflect it back to the child control and then the child control handles the message by firing events that you add your event handlers too.  This happens for other messages besides WM_NOTIFY - such as WM_COMMAND.


A few minutes with a program such as Spy++ will show you the message traffic.  When you double click a ListView item the underlying Win32 ListView sends a WM_NOTIFY message to the parent window (typically your Form).  The WinForms message handler for the parent window then reroutes the message back to the ListView by sending it a new message - WM_REFLECT + WM_NOTIFY.  The WinForms ListView message handler then dispatches it.  When the WinForms ListView sees a NM_DBLCLK notification it then sends a message (LVM_HITTEST) to the Win32 ListView control asking where the click occurred.  If it was on an item, the WinForms ListView code will then toggle the checked state of the item.


Since none of this behavior is exposed via the properties of the ListView control we'll have to work around it using less convenient means.  The solution I came up with for Team Foundation was to set a flag during the NM_DBLCLK notification that we're in the midst of a double click notification and then we intercept the LVM_HITTEST call and return that no item was found.

using System;
using System.ComponentModel;
using System.Runtime.InteropServices;
using System.Security.Permissions;
using System.Windows.Forms;
 
namespace ListViewCheckBoxes
{
    class MyListView : ListView
    {     
        private bool m_doubleClickDoesCheck = true//  maintain the default behavior
        private bool m_inDoubleClickCheckHack = false;
 
        //****************************************************************************************
        // This function helps us overcome the problem with the managed listview wrapper wanting
        // to turn double-clicks on checklist items into checkbox clicks.  We count on the fact
        // that the base handler for NM_DBLCLK will send a hit test request back at us right away.
        // So we set a special flag to return a bogus hit test result in that case.
        //****************************************************************************************
        private unsafe void OnWmReflectNotify(ref Message m)
        {
            if (!DoubleClickDoesCheck && CheckBoxes)
            {
                NativeMethods.NMHDR* nmhdr = (NativeMethods.NMHDR *)m.LParam;
 
                if (nmhdr->code == NativeMethods.NM_DBLCLK)
                {
                    m_inDoubleClickCheckHack = true;
                }
            }
        }
 
        [SecurityPermission(SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.UnmanagedCode)]
        protected override void WndProc(ref Message m)
        {
            switch (m.Msg)
            {
                //  This code is to hack around the fact that the managed listview
                //  wrapper translates double clicks into checks without giving the
                //  host to participate.
                //  See OnWmReflectNotify() for more details.
                case NativeMethods.WM_REFLECT + NativeMethods.WM_NOTIFY:
                    OnWmReflectNotify(ref m);
                    break;
 
                //  This code checks to see if we have entered our hack check for
                //  double clicking items in check lists.  During the NM_DBLCLK
                //  processing, the managed handler will send a hit test message
                //  to see which item to check.  Returning -1 will convince that
                //  code not to proceed.
                case NativeMethods.LVM_HITTEST:
                    if (m_inDoubleClickCheckHack)
                    {
                        m_inDoubleClickCheckHack = false;
                        m.Result = (System.IntPtr)(-1);
                        return;
                    }
                    break;
            }
 
            base.WndProc(ref m);
        }
 
        [Browsable(true),
         Description("When CheckBoxes is true, this controls whether or not double clicking will toggle the check."),
         Category("My Controls"),
         DefaultValue(true)]
        public bool DoubleClickDoesCheck
        {
            get
            {
                return m_doubleClickDoesCheck;
            }
 
            set
            {
                m_doubleClickDoesCheck = value;
            }
        }
    }
 
    //****************************************************************************************
    //  This is stuff you would normally put in a separate file with all the other interop
    //  you have to work with.
    //****************************************************************************************
    public class NativeMethods
    {
        public const int WM_USER = 0x0400;
        public const int WM_REFLECT = WM_USER + 0x1C00;
        public const int WM_NOTIFY = 0x004E;
        public const int LVM_HITTEST = (0x1000 + 18);
        public const int NM_DBLCLK = (-3);
 
        [StructLayout(LayoutKind.Sequential)]
        public struct NMHDR
        {
            public IntPtr hwndFrom;
            public UIntPtr idFrom;
            public int code;
        }
    }
 
}
 

Saturday, March 25, 2006

Carvin HF2 is DONE!

The Carvin HF2 "Holdsworth Fatboy" is finished and is supposed to ship Monday!

Friday, March 24, 2006

Give the .NET loader a hand - how to load assemblies from VS PrivateAssemblies

This program demonstrates how to use the AppDomain.AssemblyResolve event to help the .NET loader get assemblies loaded that it can't find.


The VS Team Foundation edition ships with a number of assemblies you may want to reference in your own apps.  Most of the important ones are installed in the GAC so you should have no problem loading them at runtime.  However, some of them are installed under the VS PrivateAssemblies directory (by default this is C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\PrivateAssemblies).  Your options are you can copy these DLLs around, put that directory in your path, put your tool in the same directory, or have .exe.config file for your app that tells the loader where to look.  Quite frankly, none of these options is particularly appealing since they all make distributing your tool more cumbersome.  So let's help the loader out!

using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Text;
using Microsoft.Win32;
 
namespace TeamFoundationAssemblyLoadTest
{
    class Program
    {
        static void Main(string[] args)
        {
            AppDomain domain = AppDomain.CurrentDomain;
 
            domain.AssemblyResolve += new ResolveEventHandler(domain_AssemblyResolve);
 
            //  The following line triggers the AssemblyResolve event to fire because
            //  it uses a class in Microsoft.TeamFoundation.WorkItemTracking.Controls.dll
            //  which is not installed in the GAC or anywhere else convenient.
            ClassThatUsesTeamFoundation.SomeFunction();
        }
 
        static Assembly domain_AssemblyResolve(object sender, ResolveEventArgs args)
        {
            String[] assemblyParams = args.Name.Split(',');
           
            Debug.Assert(assemblyParams.Length > 0 && !String.IsNullOrEmpty(assemblyParams[0]), "Invalid assembly name arguments passed to domain_AssemblyResolve");
 
            //  Note that there are additional fields passed that indicate the
            //  version, public key token, etc.  For this demonstration, we           
            //  are just looking at the assembly name.

 
            String assemblyName = assemblyParams[0];
            Assembly loadedAssembly = null;
 
            switch (assemblyName)
            {
                case "Microsoft.TeamFoundation.WorkItemTracking.Controls":
                case "Microsoft.VisualStudio.TeamFoundation":
                    // etc.
                    loadedAssembly = LoadVSPrivateAssembly(assemblyName);
                    break;
 
                default:
                    Debug.Fail(assemblyName + " is not supported by TeamFoundationAssemblyLoadTest.domain_AssemblyResolve");
                    break;
            }
 
            return loadedAssembly;
        }
 
        //  This function will load the named assembly from the Visual Studio PrivateAssemblies
        //  directory.  This is where a number of Team Foundation assemblies are located that are
        //  not easily accessible to an app.  Fortunately, the .NET loader gives us a shot at
        //  finding them and we just happen to know where to look.
        static Assembly LoadVSPrivateAssembly(String assemblyName)
        {
            Assembly loadedAssembly = null;
 
            using (RegistryKey key = Registry.LocalMachine.OpenSubKey(@"Software\Microsoft\VisualStudio\8.0"))
            {
                if (key != null)
                {
                    Object obj = key.GetValue("InstallDir");
 
                    if ((obj != null) && (obj is String))
                    {
                        String vsInstallDir = obj as String;
                        String privateAssembliesDir = Path.Combine(vsInstallDir, "PrivateAssemblies");
                        String assemblyFile = Path.Combine(privateAssembliesDir, assemblyName + ".dll");
 
                        loadedAssembly = Assembly.LoadFile(assemblyFile);
                    }
                    else
                    {
                        Debug.Fail("VS 8.0 InstallDir value is missing or invalid");
                    }
                }
                else
                {
                    Debug.Fail("Could not open VS 8.0 registry key");
                }
            }
 
            return loadedAssembly;
        }
    }
}