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

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
 
H

Herfried K. Wagner [MVP]

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
///
 
E

Engineerik

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
 
S

SurturZ

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

--
David Streeter
Synchrotech Software
Sydney Australia
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top