tags:

views:

609

answers:

2

This is a little C# specific. The default behaviour of a resizable dialog box is that title bar click maximizes the dialog and a second double click restores the size. However what I want is to have the Help button turned on, which means the minimize and maximize buttons are hidden, but would still like the title bar double click behaviour. This might be achievable with some subclassing, but perhaps someone has some good ideas on this.

+2  A: 

You should be able to handle the WM_NCHITTEST and look for HT_CAPTION, see here for details

You'll need to override the WndProc to be able to handle these messages, this is demonstrated here

Michael Prewecki
Thanks, that helped, except that it needed to be replaced by WM_NCLBUTTONDBLCLK
That is assuming of course that your user hasn't switched the buttons...I'm not sure if the OS would then see a right click but post the WM_NCLBUTTONDBLCLK message.
Michael Prewecki
A: 
    private const int WM_NCLBUTTONDBLCLK = 0xA3;

    protected override void WndProc(ref Message m)
    {
        switch (m.Msg)
        {
            case WM_NCLBUTTONDBLCLK:
                if (this.WindowState==System.Windows.Forms.FormWindowState.Maximized)
                    this.WindowState=System.Windows.Forms.FormWindowState.Normal;
                else if (this.WindowState == System.Windows.Forms.FormWindowState.Normal)
                    this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
                return;
        }
        base.WndProc(ref m);
    }