dotnet thoughts 

a dotnet developer's technical blog

Creating Wizard using Windows Forms

In my first WinForms application, I have to create various wizard screens, I couldn’t find any ready made Controls for it from Microsoft. Then one of my colleague suggested a way to tweak it, like Add a Tab Control, Set the Alignment property to bottom and add a panel on top of the Tab Control, which contains Next / Previous / Cancel buttons. It was working fine. Few days back again I got the same situation for one of my personal project, and I thought about writing a control for the same. After doing some research I found a simple code snippet, which helps to hide the Tab Pages title in Runtime.

Here is the code, in this I am extending the Tab control and overriding the WndProc event.

protected override void WndProc(ref Message m)
{
    // Hide tabs by trapping the TCM_ADJUSTRECT message
    if (m.Msg == 0x1328 && !DesignMode)
    {
        m.Result = (IntPtr)1;
    }
    else
    {
        base.WndProc(ref m);
    }
}

You can find more details about TCM_ADJUSTRECT Message on MSDN.