Catch double click on form (Catch msg in WndProc) RRS feed

  • Question

  • Hi there,

    I have written my own custom form which does not use the windows drown borders etc. One problem that I am facing is that when a user double click on the title bar that I created, the form maximizes. I don't always want this to happen as there are cases where the form should stay the defined size.

    I know that I should have a look at the WM_NCHITTEST message in WndProc(ref m), but I simply cannot catch the message for when a double click occurs.

    Any ideas on how to do this?


    Wednesday, July 30, 2008 10:27 AM


  • Found it!!

    The default system commands that are sent when you maximise your window is the SC_MAXIMIZE = 0xF030 and if you restore you window, you get the command SC_RESTORE = 0xF120.

    When you double click on the title bar, the same messages are sent but with diffirent values:
     - SC_MAXIMIZE = 0xF032
     - SC_RESTORE = 0xF122

    In order to catch the dounle click then, all you do is the following:

    if ((m.Msg == (int)0x0112 && m.WParam == (IntPtr)0xF122) ||  
                    (m.Msg == (int)0x0112 && m.WParam == (IntPtr)0xF032))  
         // ...  

    Hope this helps someone...
    • Marked as answer by Marais van Zyl Wednesday, July 30, 2008 11:48 AM
    Wednesday, July 30, 2008 11:48 AM