Click here to Skip to main content
Click here to Skip to main content

Creating an application with no taskbar icon

, 5 Jan 2000
Rate this:
Please Sign up or sign in to vote.
A simple method to create a main window that does not appear in the windows taskbar

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 PreCreateWindow override.

First, declare a window member variable in your Main Frame class:

class CMainFrame : public CFrameWnd
{
...
protected:
    CWnd m_wndInvisible;
...

Then override CMainFrame::PreCreateWindow:

BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
{
    if (!CFrameWnd::PreCreateWindow(cs))
         return FALSE;

     // Create invisible window
     if (!::IsWindow(m_wndInvisible.m_hWnd))
     {
        LPCTSTR pstrOwnerClass = AfxRegisterWndClass(0);
        if (!m_wndInvisible.CreateEx(0, pstrOwnerClass, _T(""), WS_POPUP,
                CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
                NULL, 0))
            return FALSE;
     }

    cs.hwndParent = m_wndInvisible.m_hWnd;

    return TRUE;
}

That's all you need to do! The invisible window will be automatically destroyed when the main application closes.

License

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

About the Author

Chris Maunder
Founder CodeProject
Canada Canada
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.
Follow on   Twitter   Google+   LinkedIn

Comments and Discussions

 
QuestionThis is not working for me? PinmemberSwatto8618-May-14 11:36 
GeneralMy vote of 5 Pinmemberzenkicpp30-Nov-12 13:17 
Newssumthing missing Pinmemberaddy80823-Apr-07 3:09 
GeneralVC++ Code to add application icon to the Task Manager PinmemberSmitha Rao27-Sep-06 4:03 
GeneralRe: VC++ Code to add application icon to the Task Manager Pinmemberhari_honey19-Aug-08 19:53 
Questionalt+tab PinsussAnonymous12-Sep-05 1:41 
AnswerRe: alt+tab PinmemberTorres O.19-Jan-06 12:26 
General[Message Removed] Pinmembernompel6-Oct-08 9:18 
AnswerDon't do that PinmemberElmue14-May-12 7:37 
Hello
 
Don't do that!
WS_EX_TOOLWINDOW creates an ugly caption bar without Minimize / Maximize buttons.
 
See the perfect solution here:
http://www.codeproject.com/Messages/4250481/The-perfect-solution.aspx
AnswerRe: alt+tab Pinmembersam t. xu21-Apr-06 10:11 
AnswerRe: alt+tab problem solved PinmemberElmue14-May-12 7:29 
QuestionHow I can add an icon in the left superior corner? Pinsussleoncar12-Jan-04 18:14 
QuestionHow I can add an icon in the left superior corner? Pinmemberleolim12-Jan-04 18:13 
QuestionHow to make it in Visual Basic? PinmemberMickey_vip6-Aug-03 12:40 
GeneralIncorrect icon in system dialog When Alt+Tab Pinsusskimdaejeong24-Apr-03 23:31 
QuestionHow to Create an application(base dialog) with no taskbar icon? Pinmemberzhangyifei25-Nov-02 3:40 
GeneralThis man is just great :) PinmemberAnonymous27-Mar-02 14:59 
General...or as they tell it in MSDN... PinmemberMathias13-Jan-02 23:14 
GeneralRe: ...or as they tell it in MSDN... PinmemberChris Maunder13-Jan-02 23:33 
GeneralRe: ...or as they tell it in MSDN... PinmemberMathias13-Jan-02 23:59 
GeneralRe: ...or as they tell it in MSDN... [modified] PinmemberElmue14-May-12 7:09 
AnswerThe perfect solution [modified] PinmemberElmue14-May-12 7:20 
GeneralRe: ...or as they tell it in MSDN... PinsussAnonymous22-Jul-03 20:14 
GeneralRe: ...or as they tell it in MSDN... PinsussAnonymous22-Jul-03 20:18 
QuestionHas anyone done this with Visual C++ 6.0? PinmemberSixString29-Nov-01 19:47 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Mobile
Web03 | 2.8.140709.1 | Last Updated 6 Jan 2000
Article Copyright 2000 by Chris Maunder
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid