VB's showintaskbar function analysis and implementation of VC

zhaozj2021-02-16  152

• Want to display or hide a window in the VB is easy to set a Form's showintabkbar attribute directly. But in the SDK is not a matter, one window will display a button on the taskbar in the case, in what circumstances not displayed? This is specified: 0, no matter what situation, let a window show the button on the taskbar is that the window is visible. 1. If a window is a top window (that is, the parent window is null, that is, the parent window is a desktop window), then Windows will create a button for it on the taskbar. (Exceptions, see 3) 2. If a window is not a top window, there is a WS_EX_APPWindow style, then Windows will create a button for it on the taskbar, otherwise there will be no corresponding taskbar button. 3. If a window is a top window, add WS_EX_TOOLWINDOW, and remove the WS_EX_APPWindow style, then Windows will not create a button for it on the taskbar. 4 .... I know these rules, you can control your window if you want to control your window, and give a problem and solution below. Question: In a dialog-based project in the MFC, you want the primary dialog box to display the button on the taskbar. How do I do? Solution 1: The third rule above the roots, add the WS_EX_TOOLWINDOW style and Remove the WS_EX_APPWindow style. Code: Add:? ModiFyStyleex (WS_EX_APPWINDOW, WS_EX_TOOLWINDOW, WS_EX_TOOLWINDOW, WS_EX_TOOLWINDOW, WS_EX_TOOLWINDOW, WS_EX_TOOLWINDOW, WS_EX_TOOLWINDOW, SWP_FRAMECHANGED); Remarks: This method will have a shortcoming, your dialog box will be a small title, so Most people do not use this method. Solution 2: The second rule above the roots, turn the dialog to the non-top window and removes WS_EX_APPWindow, generate a hidden dialog in the main dialog DOMODAL in the INITINSTANCE of the App class, and put this window The pointer is saved in the M_PMainWnd member variable of the CWINAPP class, and the Domodal dialog will be its sub-window. Code: Added code Bool ctestdlgapp :: initInstance () {... cfraMew mainwnd; // generate a frame window object mainwnd.create (NULL, "aa"); // Generate Window Do not bring ws_visible, that is, ctestdlgdlg DLG; m_pmainwnd = & mainwnd; // Set this hidden window to the main window int nresponse = dlg.domodal (); ...} Join in OnInitDialog in the dialog? ModifyStyleex (WS_EX_APPWINDOW, 0); in order to go out of WS_EX_APPWindow.

转载请注明原文地址:https://www.9cbs.com/read-8006.html

New Post(0)