This is a technique I first saw in Mike Blaszczak's 'stealth' program.
It is desirable sometimes to not have your application window show up in the taskbar. For instance, you may have an application resides in the system tray, and since it already has a system tray icon, having the extra icon in the taskbar is needless duplication. A simple way to create a window that will not have an icon in the taskbar is to create a separate invisible window, and have that invisible window be the parent of your applications window.
The way to do this, and still allow your application's window to remain visible, is to set the invisible window as parent in your application's
First, declare a window member variable in your Main Frame class:
class CMainFrame : public CFrameWnd
BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
LPCTSTR pstrOwnerClass = AfxRegisterWndClass(0);
if (!m_wndInvisible.CreateEx(0, pstrOwnerClass, _T(""), WS_POPUP,
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
cs.hwndParent = m_wndInvisible.m_hWnd;
That's all you need to do! The invisible window will be automatically destroyed when the main application closes.
Chris is the Co-founder, Administrator, Architect, Chief Editor and Shameless Hack who wrote and runs The Code Project. He's been programming since 1988 while pretending to be, in various guises, an astrophysicist, mathematician, physicist, hydrologist, geomorphologist, defence intelligence researcher and then, when all that got a bit rough on the nerves, a web developer. He is a Microsoft Visual C++ MVP both globally and for Canada locally.
His programming experience includes C/C++, C#, SQL, MFC, ASP, ASP.NET, and far, far too much FORTRAN. He has worked on PocketPCs, AIX mainframes, Sun workstations, and a CRAY YMP C90 behemoth but finds notebooks take up less desk space.
He dodges, he weaves, and he never gets enough sleep. He is kind to small animals.
Chris was born and bred in Australia but splits his time between Toronto and Melbourne, depending on the weather. For relaxation he is into road cycling, snowboarding, rock climbing, and storm chasing.