473,418 Members | 2,354 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,418 software developers and data experts.

Double Click in titlebar

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 buttons, and as a compromise I wish to enable
a double click on the title bar to either minimize or maximize the
form, which is doesn't do if you have a help icon!

I've googled for ages but to no avail - the closest example I have
found is in VB at
http://www.codeproject.com/Pur gatory/MouseClickOnTitlebar.as p but I
need something similar in C# and for a double click,

any help would be much appreciated!

Stu
Nov 17 '05 #1
5 6878
Stu,

Override your form's WndProc method. The following code should lead you
along the right path...

protected override void WndProc(ref Message m)
{
//WM_LBUTTONDBLCLK
if (m.Msg == 0x0203)
{

}

base.WndProc (ref m);
}

Nov 17 '05 #2
"Johann Blake" <jo*********@yahoo.com> wrote in message
news:11**********************@g47g2000cwa.googlegr oups.com...
Stu,

Override your form's WndProc method. The following code should lead you
along the right path...

protected override void WndProc(ref Message m)
{
//WM_LBUTTONDBLCLK
if (m.Msg == 0x0203)
{

}

base.WndProc (ref m);
}


To trap a double click in the title bar I think you need to handle the
WM_NCLBUTTONDBLCLK message (value 0x00A3) rather than WM_LBUTTONDBLCLK.

Chris Jobson

Nov 17 '05 #3
"Johann Blake" <jo*********@yahoo.com> wrote in message
news:11**********************@g47g2000cwa.googlegr oups.com...
Stu,

Override your form's WndProc method. The following code should lead you
along the right path...

protected override void WndProc(ref Message m)
{
//WM_LBUTTONDBLCLK
if (m.Msg == 0x0203)
{

}

base.WndProc (ref m);
}


To trap a double click in the title bar I think you need to handle the
WM_NCLBUTTONDBLCLK message (value 0x00A3) rather than WM_LBUTTONDBLCLK.

Chris Jobson

Nov 17 '05 #4
Thankyou! This is how I've done it, it's pretty hacky because when the form
is in the maximised state the double click event in the title bar is fired
and the form gets minimized automatically, so I've had to use a flag to say
when I've fired my own maximize

private bool m_bSelfMaximiseFlag = false;
protected override void WndProc(ref Message m)
{
base.WndProc (ref m);
if(m.Msg == 0x00A3)
{
if((this.WindowState==FormWindowState.Normal)&&(!m _bSelfMaximiseFlag))
{
this.WindowState=FormWindowState.Maximized;
m_bSelfMaximiseFlag = true;
}
else
{
m_bSelfMaximiseFlag = false;
}
}
}
Nov 17 '05 #5
Thankyou! This is how I've done it, it's pretty hacky because when the form
is in the maximised state the double click event in the title bar is fired
and the form gets minimized automatically, so I've had to use a flag to say
when I've fired my own maximize

private bool m_bSelfMaximiseFlag = false;
protected override void WndProc(ref Message m)
{
base.WndProc (ref m);
if(m.Msg == 0x00A3)
{
if((this.WindowState==FormWindowState.Normal)&&(!m _bSelfMaximiseFlag))
{
this.WindowState=FormWindowState.Maximized;
m_bSelfMaximiseFlag = true;
}
else
{
m_bSelfMaximiseFlag = false;
}
}
}
Nov 17 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

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...
6
by: Richard A. Lowe | last post by:
I'm using P/Invoke to call SendInput (using code culled from these newsgroups!) to send mouse events to a window. But I'm unsure how to send double-clicks. A VB6 article I saw on SendInput...
4
by: perspolis | last post by:
hi I manage a double click event in a combo box.. but this event doesn't fire ???? I don't know why??
3
by: Siv | last post by:
Hi, I have a ListView control in a Windows application, currently single clicking a customer name in this list, selects the customer and displays their details in text boxes to the right of the...
5
by: Nick | last post by:
Hey guys, I have 2 events on a windows forms datagrid, the mouse move as well as the double click events. What's happening is that when I double click on a row in the grid, the mouse move event...
1
by: scott_gui | last post by:
Creating a Windows application: <Double-Button-1> mouse event has a conflict when there is also a binding to the <Button-1> event. It seems like a silly oversight that performing a double click...
2
by: scott_gui | last post by:
I am creating a Windows application: The mouse event <Double-Button-1> has a conflict when the <Button-1> event also has a binding. Double clicks will first perform the single click action. This...
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...
6
by: Jim Devenish | last post by:
I have an unbound form that displays all the days of the year as a calendar. It has 12 rows of text boxes with either 29,30 or 31 in each row. Text box names are of the form: display_01_01,...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.