views:

141

answers:

1

A .NET Windows form can have a help button on the title bar when the HelpButton property is set to true (and you are not displaying minimize/maximize buttons). When this help button is clicked, the form goes into a help mode where the cursor changes and clicking elsewhere in the form does not have the usual effect. Instead a click induces the HelpRequested event on the clicked control. Great, except that I need the help button AND the minimize/maximize buttons. So I have created my own help button in the client area of my form. When it is clicked, how can I place the form in help mode?

+1  A: 

Found it.

[DllImport("user32.dll")] private static extern int SendMessage(IntPtr hwnd, int msg, IntPtr wp, IntPtr lp);
private const int WM_SYSCOMMAND = 0x112;
private const int SC_CONTEXTHELP = 0xf180;

private void button1_Click(object sender, EventArgs e) {
  button1.Capture = false;
  SendMessage(this.Handle, WM_SYSCOMMAND, (IntPtr)SC_CONTEXTHELP, IntPtr.Zero);
}
Fantius