Hide a form's taskbar button without using WS_EX_TOOLWIN

前端 未结 7 2196
太阳男子
太阳男子 2020-12-16 06:59

I need to hide a Windows form from the taskbar but I can\'t use WS_EX_TOOLWINDOW because I need the system menu and min/max buttons on the form\'s title bar.

7条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-16 07:22

    There's an interesting discussion of this exact problem here (from a VB6 persepective).

    The most relevant bit from your question's perspective is:

    "When you create a window, the taskbar examines the window's extended style to see if either the WS_EX_APPWINDOW (&H40000) or WS_EX_TOOLWINDOW (&H80) style is turned on. If WS_EX_APPWINDOW is turned on, the taskbar shows a button for the window, and if WS_EX_ TOOLWINDOW is turned on, the taskbar does not show a button for the window. A window should never have both of these extended styles. If the window doesn't have either of these styles, the taskbar decides to create a button if the window is unowned and does not create a button if the window is owned."

    Incidentally, you use the GetWindow API function with the GW_OWNER flag to determine whether a window is owned.

提交回复
热议问题