开发者

How to do context help ("what is this?" button) in WinForms?

开发者 https://www.devze.com 2022-12-21 22:43 出处:网络
How to make \"what is this?\" button like those in top-right corner of dialogu开发者_开发技巧e boxes. I cant set Form.HelpButton to true because I have Minimize & Maximize buttons there.You can\'t

How to make "what is this?" button like those in top-right corner of dialogu开发者_开发技巧e boxes. I cant set Form.HelpButton to true because I have Minimize & Maximize buttons there.


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);
0

精彩评论

暂无评论...
验证码 换一张
取 消