473,320 Members | 1,580 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

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 10416
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: yair | last post by:
hey all i have a page with a table, and when the user doubleclicks a row in it, a window is opened. The problem is, if he doubleclicked a text in the row, it's becoming selected. what i want is...
3
by: tolisss | last post by:
Hi I have a form with minimize,maximize button=false and startup window state= maximized but when the user double click on the form title bar caption the form's size changes How do i prevent...
5
by: satankidneypie | last post by:
Hi, does anyone have any idea how to trap a double click event in the title bar of a form? I'm wanting to use help icons on titlebars, but this means that I can't have minimize or maximize...
3
by: snake_2k | last post by:
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...
1
by: Brett Romero | last post by:
I'm allowing double clicks on a DataGrid by using a counter and timing. However, the user must click two different cells for the double click to work. The reason is once they click into a cell, it...
9
by: Armando | last post by:
I have an app (A2000) where I am letting the user move an object on the screen. I use the OnClick for a command button event to modify the object's Top (or Left) properties, but you can only click...
1
by: Dan Reber | last post by:
(Originally posted to WindowsForms newsgroup with no response, is there a Visual Studio newsgroup?) There are times when I mistakenly double-click a control and then VS goes to the code window...
1
by: JT | last post by:
Hi, I want to disable the ability to launch an application that is embedded in the text of a RichTextBox control. I've seen various posts that say that doing the following will disable click...
2
by: richard.nigro | last post by:
When you double-click on a control in the designer window, it creates the 'default' event for that control. Is there any way to disable this functionality?
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.