Add a help button, but continue to maximize and minimize

I would like to add a help button to my winform, but keep the maxmimize and minim buttons, but the Windows standard will disable both buttons to show the help button.

There is already a question: β€œ How to enable help?” In the winform title bar - but in this question the person who asked the question is pleased with the removal of these two buttons to show the help.

Is it possible that I can have help, maximum, minimum and closing buttons at the same time?

Thanks.

+6
source share
2 answers

Windows does not support showing both. A workaround is to provide your own button to trigger the same action. Place it somewhere near the upper right corner. You start this by sending yourself a WM_SYSCOMMAND message, like the standard help button. 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); 

The name of the button is assumed to be Help.

+6
source

One way to do this is to create your own border.

 FormBorderStyle = None 

Now create your own header area. This is not trivial because you need to handle zoom, transparency, if you want rounded corners, etc.

+1
source

Source: https://habr.com/ru/post/918665/


All Articles