问题描述
我希望能够将帮助按钮添加到我的winform上,但是保留最大化和最小化按钮,但是Windows标准是禁用这两者,以便能够显示帮助按钮.
I would like to be able to add the help button onto my winform, but keep the maxmimize and minimize buttons, but windows standard is to disable both to be able to show the help button.
已经有一个类似的问题:如何包含帮助?"在winform的标题栏中-但在那个问题中,提出这个问题的人很满意,就是删除了这两个用于显示帮助的按钮.
There is already a question similar:How to include help '?' in title bar of winform -but in that question the one who asked the question is content with removing those 2 buttons for the help to show.
我可以同时在所有位置获得帮助,最大,最小和关闭按钮吗?
Is there away that i can have help, max, min and close buttons all there at the same time?
谢谢.
推荐答案
Windows不支持同时显示两者.一种解决方法是提供您自己的按钮以触发相同的操作.将其放在右上角附近的某个地方.您可以通过向自己发送WM_SYSCOMMAND消息来触发此操作,就像标准帮助按钮一样.像这样:
Windows doesn't support showing both. A workaround is to provide your own button to trigger the same action. Put it somewhere close to the upper right corner. You trigger this by sending yourself a WM_SYSCOMMAND message, just like the standard help button does. Like this:
private void Help_Click(object sender, EventArgs e) {
Help.Capture = false;
SendMessage(this.Handle, WM_SYSCOMMAND, (IntPtr)SC_CONTEXTHELP, IntPtr.Zero);
}
private const int WM_SYSCOMMAND = 0x112;
private const int SC_CONTEXTHELP = 0xf180;
[System.Runtime.InteropServices.DllImport("user32.dll")]
private static extern IntPtr SendMessage(IntPtr hWnd, int msg, IntPtr wp, IntPtr lp);
假定按钮的名称为帮助".
Which assumes that button's name is "Help".
这篇关于添加帮助按钮,但保持最大化和最小化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!