Ok, so I use this code to hide the dialog-based MFC application taskbar icon (VC ++). The taskbar icon and dialog box are hidden whenever I click the cross or close buttons. But I canβt get it right. Whenever I click the close or cross button in the title bar, the dialog box first flickers and shows a kind of intermediate dialog box, and then it hides. This is very annoying. I post my code here after two days of futile effort. So guys, please help me. Thanks in advance.
void CMyAppDlg::OnBnClickedCancel() { // TODO: Add your control notification handler code here CWnd* pWnd; pWnd = AfxGetMainWnd(); RemoveTaskbarIcon(pWnd); pWnd->ModifyStyle(WS_VISIBLE, 0); mVisible = FALSE; } BOOL CMyAppDlg::RemoveTaskbarIcon(CWnd* pWnd) { LPCTSTR pstrOwnerClass = AfxRegisterWndClass(0); // Create static invisible window if (!::IsWindow(mWndInvisible.m_hWnd)) { if (!mWndInvisible.CreateEx(0, pstrOwnerClass, _T(""), WS_POPUP, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, 0)) return FALSE; } pWnd->SetParent(&mWndInvisible); return TRUE; }
Here are the screenshots of the dialog box. When I click the close or cross button, a dialog box that looks like this first turns to this in less than half a second, and then disappears (hides).
source share