Click here to Skip to main content
11,429,777 members (75,443 online)
Click here to Skip to main content

Creating an application with no taskbar icon

, 5 Jan 2000 CPOL
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)

Share

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? Pin
Swatto8618-May-14 12:36
memberSwatto8618-May-14 12:36 
GeneralMy vote of 5 Pin
zenkicpp30-Nov-12 14:17
memberzenkicpp30-Nov-12 14:17 
Newssumthing missing Pin
addy80823-Apr-07 4:09
memberaddy80823-Apr-07 4:09 
GeneralVC++ Code to add application icon to the Task Manager Pin
Smitha Rao27-Sep-06 5:03
memberSmitha Rao27-Sep-06 5:03 
GeneralRe: VC++ Code to add application icon to the Task Manager Pin
hari_honey19-Aug-08 20:53
memberhari_honey19-Aug-08 20:53 
Questionalt+tab Pin
Anonymous12-Sep-05 2:41
sussAnonymous12-Sep-05 2:41 
AnswerRe: alt+tab Pin
Torres O.19-Jan-06 13:26
memberTorres O.19-Jan-06 13:26 
General[Message Removed] Pin
nompel6-Oct-08 10:18
membernompel6-Oct-08 10:18 
AnswerDon't do that Pin
Elmue14-May-12 8:37
memberElmue14-May-12 8:37 
AnswerRe: alt+tab Pin
sam t. xu21-Apr-06 11:11
membersam t. xu21-Apr-06 11:11 
AnswerRe: alt+tab problem solved Pin
Elmue14-May-12 8:29
memberElmue14-May-12 8:29 
QuestionHow I can add an icon in the left superior corner? Pin
leoncar12-Jan-04 19:14
sussleoncar12-Jan-04 19:14 
QuestionHow I can add an icon in the left superior corner? Pin
leolim12-Jan-04 19:13
memberleolim12-Jan-04 19:13 
QuestionHow to make it in Visual Basic? Pin
Mickey_vip6-Aug-03 13:40
memberMickey_vip6-Aug-03 13:40 
GeneralIncorrect icon in system dialog When Alt+Tab Pin
kimdaejeong25-Apr-03 0:31
susskimdaejeong25-Apr-03 0:31 
QuestionHow to Create an application(base dialog) with no taskbar icon? Pin
zhangyifei25-Nov-02 4:40
memberzhangyifei25-Nov-02 4:40 
GeneralThis man is just great :) Pin
Anonymous27-Mar-02 15:59
memberAnonymous27-Mar-02 15:59 
General...or as they tell it in MSDN... Pin
Mathias14-Jan-02 0:14
memberMathias14-Jan-02 0:14 
GeneralRe: ...or as they tell it in MSDN... Pin
Chris Maunder14-Jan-02 0:33
memberChris Maunder14-Jan-02 0:33 
GeneralRe: ...or as they tell it in MSDN... Pin
Mathias14-Jan-02 0:59
memberMathias14-Jan-02 0:59 
GeneralRe: ...or as they tell it in MSDN... [modified] Pin
Elmue14-May-12 8:09
memberElmue14-May-12 8:09 
AnswerThe perfect solution [modified] Pin
Elmue14-May-12 8:20
memberElmue14-May-12 8:20 
GeneralRe: ...or as they tell it in MSDN... Pin
Anonymous22-Jul-03 21:14
sussAnonymous22-Jul-03 21:14 
GeneralRe: ...or as they tell it in MSDN... Pin
Anonymous22-Jul-03 21:18
sussAnonymous22-Jul-03 21:18 
QuestionHas anyone done this with Visual C++ 6.0? Pin
SixString29-Nov-01 20:47
memberSixString29-Nov-01 20:47 
AnswerRe: Has anyone done this with Visual C++ 6.0? Pin
Albert van Peppen18-Dec-02 4:03
memberAlbert van Peppen18-Dec-02 4:03 
GeneralTop banana! Pin
Baz4-Apr-01 0:16
memberBaz4-Apr-01 0:16 
QuestionWhat About Console Application? Pin
Anonymous12-Jan-01 13:32
memberAnonymous12-Jan-01 13:32 
GeneralJava Pin
Nick20-Jul-00 13:48
sussNick20-Jul-00 13:48 
QuestionHow do you do this in Delphi? Pin
Rick Ashford13-Apr-00 20:01
sussRick Ashford13-Apr-00 20:01 
QuestionHow to avoid task being removed from task list ( in the Task Manager)? Pin
Bernd Giesen7-Apr-00 4:23
sussBernd Giesen7-Apr-00 4:23 
QuestionWorking for Dialog based Apps!! The correct way? Pin
Albert van Peppen6-Apr-00 3:52
sussAlbert van Peppen6-Apr-00 3:52 
AnswerRe: Working for Dialog based Apps!! The correct way? Pin
Martin Schmid16-Apr-00 18:57
sussMartin Schmid16-Apr-00 18:57 
AnswerRe: Working for Dialog based Apps!! The correct way? Pin
Anonymous14-May-01 4:05
memberAnonymous14-May-01 4:05 
AnswerRe: Working for Dialog based Apps!! The correct way? Pin
Wolle4-Aug-01 1:21
memberWolle4-Aug-01 1:21 
GeneralRe: Working for Dialog based Apps!! The correct way? Pin
Wolle4-Aug-01 9:30
memberWolle4-Aug-01 9:30 
AnswerRe: Working for Dialog based Apps!! The correct way? Pin
RobJones28-Nov-01 16:48
memberRobJones28-Nov-01 16:48 
GeneralRe: Working for Dialog based Apps!! The correct way? Pin
Albert van Peppen9-Jan-02 22:14
memberAlbert van Peppen9-Jan-02 22:14 
AnswerRe: Working for Dialog based Apps!! The correct way? Pin
Riccardo Modesti18-Jan-02 3:32
memberRiccardo Modesti18-Jan-02 3:32 
GeneralRe: Working for Dialog based Apps!! The correct way? Pin
Waleed17-Apr-02 14:03
memberWaleed17-Apr-02 14:03 
AnswerRemove WS_EX_APPWINDOW easier. and TOGGLE ...? Pin
Behzad Ebrahimi17-Dec-02 22:46
memberBehzad Ebrahimi17-Dec-02 22:46 
Your idea work for me good[yet] and is niceRoll eyes | :rolleyes: .

Also I think that to remove the WS_EX_APPWINDOW just add the simple following
command to your C---Dlg::OnInitDialog();


CMyDialog::OnInitDialog()
{
...
ModifyStyleEx( WS_EX_APPWINDOW, 0 );
...
}


Is it easy?Blush | :O

... and a question:Cool | :cool:

How can toggle to view taskbar button? such as winamp[^].

GeneralRe: Remove WS_EX_APPWINDOW easier. and TOGGLE ...? Pin
otwesten14-Apr-03 6:12
sussotwesten14-Apr-03 6:12 
AnswerRe: Working for Dialog based Apps!! The correct way? Pin
Anonymous16-Nov-04 19:41
sussAnonymous16-Nov-04 19:41 
AnswerRe: Working for Dialog based Apps!! The correct way? - How to fix the ALT+TAB icon Pin
DLChambers10-Jan-07 8:17
memberDLChambers10-Jan-07 8:17 
AnswerRe: Working for Dialog based Apps!! The correct way? Pin
KienNT787-Mar-08 21:22
memberKienNT787-Mar-08 21:22 
GeneralNot totally invisible Pin
kabir20-Mar-00 5:30
susskabir20-Mar-00 5:30 
GeneralRe: Not totally invisible Pin
AliAkbar Rashidi2-Apr-01 23:52
memberAliAkbar Rashidi2-Apr-01 23:52 
GeneralRe: Not totally invisible Pin
Shengqian Ji19-Apr-02 4:33
memberShengqian Ji19-Apr-02 4:33 
GeneralIts far easier to do with dialog Apps ! Pin
Colin Davies13-Jan-00 10:03
sussColin Davies13-Jan-00 10:03 
GeneralRe: Its far easier to do with dialog Apps ! Pin
Martin MacRobert25-Jan-00 10:58
sussMartin MacRobert25-Jan-00 10:58 

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 | Terms of Use | Mobile
Web03 | 2.8.150428.2 | Last Updated 6 Jan 2000
Article Copyright 2000 by Chris Maunder
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid