The easiest way is probably to set the forms window style ControlBox = False
and MinimizeBox = False
and then call SHDoneButton in the form's Paint event handler and when it's activated or shown. You really are only supposed to need to do it before the form becomes the foreground window but I found that you have to also call it in the Paint event handler. So SHDoneButton(this.handle, SHDB_SHOW)
where SHDB_SHOW = 0x0001
you'll need:
[DllImport("aygshell.dll")]
public static extern bool SHDoneButton(IntPtr hWnd, UInt32 dwState);
somewhere as well.
Per the linked documentation:
Typically, the Done button is managed by the shell, and showing or hiding the OK button happens automatically. A top-level window that needs the Done button to appear should use the WS_EX_CAPTIONOKBTN window style.
To make the OK button appear, ensure that your window does not have either the WS_CAPTION or WS_CHILD styles.
Whenever the foreground window changes, the shell checks the style bits of the window to determine if the OK button should appear in the taskbar. The OK button takes precedence over a menu bar added to the taskbar.