Click here to Skip to main content
15,884,013 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How to hide the Program ICON in the task bar in Win8.1.
I tried the API ModifyStyleEx(WS_EX_APPWINDOW, WS_EX_TOOLWINDOW), but not worked.
C++
void CMFC_NotifyIconDlg::ShowHide(bool flag)
{
	static CRect TmpRect;

	if (flag)
	{//show
		ModifyStyleEx(WS_EX_TOOLWINDOW, WS_EX_APPWINDOW);

		AfxGetApp()->GetMainWnd()->ShowWindow(SW_SHOW);
		ShowWindow(SW_SHOW);

		AfxGetMainWnd()->MoveWindow(TmpRect.left, TmpRect.top, TmpRect.Width(), TmpRect.Height(), true); 
	}
	else
	{//hide
		GetWindowRect(&TmpRect);/
		ModifyStyleEx(WS_EX_APPWINDOW, WS_EX_TOOLWINDOW);

		AfxGetApp()->GetMainWnd()->ShowWindow(SW_HIDE);
		ShowWindow(SW_HIDE);
		AfxGetMainWnd()->MoveWindow(-TmpRect.right, -TmpRect.bottom, TmpRect.Width(), TmpRect.Height(), true); 
	}
}


What I have tried:

https://msdn.microsoft.com/zh-cn/library/61fe4bte.aspx
WS_EX_TOOLWINDOW Creates a tool window, which is a window intended to be used as a floating toolbar.A tool window has a title bar that is shorter than a normal title bar, and the window title is drawn using a smaller font.A tool window does not appear in the task bar or in the window that appears when the user presses ALT+TAB.
Posted
Updated 20-May-16 3:21am
Comments
Richard MacCutchan 20-May-16 4:08am    
You should check the return value from your calls to ModifyStyleEx to see if they succeeded. Not all styles can be changed after a Window has been created.

1 solution

The issue is that you must use WS_EX_TOOLWINDOW when you first create the Window. It will then not show up on the task bar. But if you change its type at a later time it will still not show. The type of Window is established at create time.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900