Double click event on Windows Form Title Bar

double click event on title bar

Double click event on Windows Form Title Bar

When you people want to work with windows forms then you will see there is not predefined event method for detecting double clicks on title bar when you off the maximize button of title bar.

After googling i didnt find any direct solution of this problem. But in asp.net forum someone looking for mouseEeventup [http://forums.microsoft.com/Forums/ShowPost.aspx?PostID=3596344&SiteID=1] where I got the code.

I found there is way to detect double click by overriding wndproc method.You can detect any kind of event with this method. You just have to know code or name of that event. The code given below is tested and it rocks.


    protected override void WndProc(ref Message m)
    {
        switch (m.Msg)
        {
            case (0x00A1): //WM_NCLButtonDown
                //do somthing,
                break;
            case (0x00A2):
                //WM_NCLButtonUp
                //happend only on double-click
                break;
        }

        base.WndProc(ref m);
    }

 

Tags:tech 
Comments(0) Posted By saiket | 7/4/2008 3:44:00 AM