From: AussieRules on
Hi,

I have a form that is set to being maximised. I have disabled the min/max
buttons and set the formborderstyle to be fixedtoolwindow.

Once the application has started it maximise just fine, but the user can
then dbl click the window title bar and it is no longer maximised.

My application is a touch screen application and therefore the number of
accidental double clicks occuring that result in the form no longer
remaining maximised is a problem

Is there away to have the for start up maximised, and then disable all form
resizes or moves, with exception to the close form button...

Thanks

From: Onur Güzel on
On May 4, 5:57 pm, "AussieRules" <nos...(a)nospam.com> wrote:
> Hi,
>
> I have a form that is set to being maximised. I have disabled the min/max
> buttons and set the formborderstyle to be fixedtoolwindow.
>
> Once the application has started it maximise just fine, but the user can
> then dbl click the window title bar and it is no longer maximised.
>
> My application is a touch screen application and therefore the number of
> accidental double clicks occuring that result in the form no longer
> remaining maximised is a problem
>
> Is there away to have the for start up maximised, and then disable all form
> resizes or moves, with exception to the close form button...
>
> Thanks

Hi Aussie,

Preventing double-click behaviour seems that it requires using Win32
API such as mouse_event and overriding WndProc. So add the following
code in your form's code file:

'------------------------------------------------
Declare Sub mouse_event Lib "user32" _
Alias "mouse_event" (ByVal dwFlags As Integer, _
ByVal dx As Integer, ByVal dy As Integer, _
ByVal cButtons As Integer, ByVal dwExtraInfo _
As Integer)

Protected Overrides Sub DefWndProc _
(ByRef m As System.Windows.Forms.Message)
If CLng(m.Msg) = &HA1 Then
mouse_event(&H4, 0, 0, 0, 1)
mouse_event(&H20, 0, 0, 0, 1)
mouse_event(&H40, 0, 0, 0, 1)
End If
MyBase.DefWndProc(m)
End Sub
'------------------------------------------------

Thus, you won't be able to minimize your form with double-clicking on
title bar in addition with disabling MaximizeBox and MinimizeBox.

HTH,

Onur Güzel