2

How to make "what is this?" button like those in top-right corner of dialogue boxes. I cant set Form.HelpButton to true because I have Minimize & Maximize buttons there.

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Poma
  • 8,174
  • 18
  • 82
  • 144

1 Answers1

3

You can't. You either get the min/max buttons OR the help button. These are standard Windows UI guidelines, the help button should only appear on dialogs and dialogs shouldn't have min/max buttons.

You can solve you problem with a wee bit of P/Invoke. Add a What's This button to your UI and implement its Click event like this:

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

private const int SC_CONTEXTHELP = 0xf180;
private const int WM_SYSCOMMAND = 0x112;

[System.Runtime.InteropServices.DllImport("user32.dll")]
private static extern IntPtr SendMessage(IntPtr hWnd, int msg, IntPtr wp, IntPtr lp);
Hans Passant
  • 922,412
  • 146
  • 1,693
  • 2,536