Prevent Form Un-maximizing when titlebar is double-clicked.

  • Thread starter Thread starter Engineerik
  • Start date Start date
E

Engineerik

I have a form which is maximized when I show it.
The form maximize button is not enabled so cannot be used to un-maximize the
form. However, if a double-click is done on the form titlebar the form
resizes to its unmaximized size.
I know I can change the unmaximized size to be equal to the maximized size
but is there a way to prevent the un-maximize that occurs when the form
titlebar is doubleclicked?

Erik Warren
 
Engineerik said:
I have a form which is maximized when I show it.
The form maximize button is not enabled so cannot be used to un-maximize
the
form. However, if a double-click is done on the form titlebar the form
resizes to its unmaximized size.
I know I can change the unmaximized size to be equal to the maximized size
but is there a way to prevent the un-maximize that occurs when the form
titlebar is doubleclicked?

You may want to listen for the 'WM_NCLBUTTONDBLCLK' message in your form's
'WndProc' and "eat" this message if the form's 'WindowState' property is set
to 'Maximized'.

\\\
Private Const WM_NCLBUTTONDBLCLK As Int32 = &HA3
///
 
Herfried K. Wagner said:
You may want to listen for the 'WM_NCLBUTTONDBLCLK' message in your form's
'WndProc' and "eat" this message if the form's 'WindowState' property is set
to 'Maximized'.

\\\
Private Const WM_NCLBUTTONDBLCLK As Int32 = &HA3
///

This does the trick:

Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
Const WM_NCLBUTTONDBLCLK As Int32 = &HA3
If m.Msg = WM_NCLBUTTONDBLCLK Then
Exit Sub
End If
MyBase.WndProc(m)
End Sub


Thanks,
Erik Warren
 
If you don't mind losing the form title bar, then set Form.ControlBox=False
and Form.Text=""

--
David Streeter
Synchrotech Software
Sydney Australia
 
Back
Top