472,135 Members | 1,491 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,135 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 6548
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by snake_2k | last post: by
6 posts views Thread by Richard A. Lowe | last post: by
4 posts views Thread by perspolis | last post: by
1 post views Thread by scott_gui | last post: by
2 posts views Thread by scott_gui | last post: by
9 posts views Thread by Armando | last post: by
6 posts views Thread by Jim Devenish | last post: by
reply views Thread by leo001 | last post: by

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.