Stop menu popup when a Window's icon is clicked?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Is it possible to stop the menu from appearing when you click the icon on a
Window's title bar? I'm wanting to use it as a button for a different
purpose. I've tried capturing all the messages that run through wndproc but
none of them relate to this menu.

Please help,

Darrell
 
redneon said:
Is it possible to stop the menu from appearing when you click the icon on
a
Window's title bar? I'm wanting to use it as a button for a different
purpose. I've tried capturing all the messages that run through wndproc
but
none of them relate to this menu.

Yes, it's possible and you're on the right track. Try this:

protected override void WndProc(ref Message m)
{
const int WM_NCHITTEST = 0x0084;
const int HTCAPTION = 2;
const int HTSYSMENU = 3;

base.WndProc(ref m);

if (m.Msg == WM_NCHITTEST && m.Result == (IntPtr)HTSYSMENU)
{
// Window icon clicked
m.Result = (IntPtr)HTCAPTION;
}
}

This will disable the icon; clicking on it will have the same effect as
clicking
elsewhere on the title bar. Search WinUser.h for other possible HT values.

- Magnus
 
Back
Top