469,271 Members | 1,776 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,271 developers. It's quick & easy.

Disable resize on titlebar double click

I need to know how to intercept and neutralize the doubleclick event that
happens when someone double clicks the titlebar of a window.

I borrowed some encapsulation code that keeps the user from moving the form,
and have set the form's min height and width value to its fullscreen values.
But when I double click the title bar it flashes the window to a smaller size
then restores it to the fullscreen size, but moved a few pixels the the
bottom right. I want to stop this from happening at all.
FYI here is the code for an object that encapsulates a Form object and adds
a Movable property for anyone interested. Add this as a new class then
change what the form inherits to MovableForm

from http://dotnet.mvps.org/dotnet/faqs/?...leform&lang=en

///////////////code below

Imports System.ComponentModel
Imports System.Windows.Forms

Public Class MoveableForm
Inherits Form

Private Const WM_NCLBUTTONDOWN As Int32 = &HA1
Private Const WM_SYSCOMMAND As Int32 = &H112

Private Const HTCAPTION As Int32 = &H2

Private Const SC_MOVE As Int32 = &HF010

Private m_Moveable As Boolean

Public Sub New()
MyBase.New()
Me.Moveable = True
End Sub

< _
Category("Behavior"), _
Description("Allows the form to be moved.") _
_

Public Property Moveable() As Boolean
Get
Return m_Moveable
End Get
Set(ByVal Value As Boolean)
m_Moveable = Value
End Set
End Property

Protected Overrides Sub WndProc(ByRef m As Message)
If Not m_Moveable Then
If _
m.Msg = WM_SYSCOMMAND And _
m.WParam.ToInt32() = SC_MOVE _
OrElse _
m.Msg = WM_NCLBUTTONDOWN And _
m.WParam.ToInt32() = HTCAPTION _
Then
Return
End If
End If
MyBase.WndProc(m)
End Sub

Private Sub MoveableForm_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

End Sub

Private Sub InitializeComponent()
'
'MoveableForm
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(292, 273)
Me.Name = "MoveableForm"

End Sub
End Class
Jul 21 '05 #1
3 9763
Form.MaximizeBox = False

This will stop the double click from doing anything.

Also Form.ControlBox = False has the same effect

Chris
"snake_2k" <sn*****@discussions.microsoft.com> wrote in message
news:0B**********************************@microsof t.com...
I need to know how to intercept and neutralize the doubleclick event that
happens when someone double clicks the titlebar of a window.

I borrowed some encapsulation code that keeps the user from moving the
form,
and have set the form's min height and width value to its fullscreen
values.
But when I double click the title bar it flashes the window to a smaller
size
then restores it to the fullscreen size, but moved a few pixels the the
bottom right. I want to stop this from happening at all.
FYI here is the code for an object that encapsulates a Form object and
adds
a Movable property for anyone interested. Add this as a new class then
change what the form inherits to MovableForm

from http://dotnet.mvps.org/dotnet/faqs/?...leform&lang=en

///////////////code below

Imports System.ComponentModel
Imports System.Windows.Forms

Public Class MoveableForm
Inherits Form

Private Const WM_NCLBUTTONDOWN As Int32 = &HA1
Private Const WM_SYSCOMMAND As Int32 = &H112

Private Const HTCAPTION As Int32 = &H2

Private Const SC_MOVE As Int32 = &HF010

Private m_Moveable As Boolean

Public Sub New()
MyBase.New()
Me.Moveable = True
End Sub

< _
Category("Behavior"), _
Description("Allows the form to be moved.") _
> _

Public Property Moveable() As Boolean
Get
Return m_Moveable
End Get
Set(ByVal Value As Boolean)
m_Moveable = Value
End Set
End Property

Protected Overrides Sub WndProc(ByRef m As Message)
If Not m_Moveable Then
If _
m.Msg = WM_SYSCOMMAND And _
m.WParam.ToInt32() = SC_MOVE _
OrElse _
m.Msg = WM_NCLBUTTONDOWN And _
m.WParam.ToInt32() = HTCAPTION _
Then
Return
End If
End If
MyBase.WndProc(m)
End Sub

Private Sub MoveableForm_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

End Sub

Private Sub InitializeComponent()
'
'MoveableForm
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(292, 273)
Me.Name = "MoveableForm"

End Sub
End Class

Jul 21 '05 #2
That keeps the form from resizing, but if I double click the title bar the
window still flashes to a smaller size then restores slightly out of place.
My border style is fixed single, the form has no minimize or maximize
buttons, and i used the code above to keep the user from moving the form at
all. I still would like to keep the window from flashing, restoring, then
moving off center when i double click the title bar,.

"Chris, Master of All Things Insignifican" wrote:
Form.MaximizeBox = False

This will stop the double click from doing anything.

Also Form.ControlBox = False has the same effect

Chris


Jul 21 '05 #3
I have been also looking how to disable resize on titlebare on doubleclick for quite some time. Still have not found anything. Did you ever get an answer. If you did can you please share. Thank you -Vitaly

From http://www.developmentnow.com/g/34_2...uble_click.htm

Posted via DevelopmentNow Groups
www.developmentnow.com/g
www.developmentnow.com
Jul 21 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by yair | last post: by
3 posts views Thread by tolisss | last post: by
5 posts views Thread by satankidneypie | last post: by
3 posts views Thread by snake_2k | last post: by
1 post views Thread by Brett Romero | last post: by
9 posts views Thread by Armando | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.