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

Creating an application with no taskbar icon

By , 5 Jan 2000
 

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
Member
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.

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
Hint: For improved responsiveness ensure Javascript is enabled and choose 'Normal' from the Layout dropdown and hit 'Update'.
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
GeneralMy vote of 5memberzenkicpp30 Nov '12 - 13:17 
Newssumthing missingmemberaddy80823 Apr '07 - 3:09 
GeneralVC++ Code to add application icon to the Task ManagermemberSmitha Rao27 Sep '06 - 4:03 
GeneralRe: VC++ Code to add application icon to the Task Managermemberhari_honey19 Aug '08 - 19:53 
Questionalt+tabsussAnonymous12 Sep '05 - 1:41 
AnswerRe: alt+tabmemberTorres O.19 Jan '06 - 12:26 
General[Message Removed]membernompel6 Oct '08 - 9:18 
AnswerDon't do thatmemberElmue14 May '12 - 7:37 
AnswerRe: alt+tabmembersam t. xu21 Apr '06 - 10:11 
AnswerRe: alt+tab problem solvedmemberElmue14 May '12 - 7:29 
Hello
 
Your answer is correct but why not simply posting the code which avoids misunderstandings?
 
Here is the code:
http://www.codeproject.com/Messages/4250481/The-perfect-solution.aspx
QuestionHow I can add an icon in the left superior corner?sussleoncar12 Jan '04 - 18:14 
QuestionHow I can add an icon in the left superior corner?memberleolim12 Jan '04 - 18:13 
QuestionHow to make it in Visual Basic?memberMickey_vip6 Aug '03 - 12:40 
GeneralIncorrect icon in system dialog When Alt+Tabsusskimdaejeong24 Apr '03 - 23:31 
QuestionHow to Create an application(base dialog) with no taskbar icon?memberzhangyifei25 Nov '02 - 3:40 
GeneralThis man is just great :)memberAnonymous27 Mar '02 - 14:59 
General...or as they tell it in MSDN...memberMathias13 Jan '02 - 23:14 
GeneralRe: ...or as they tell it in MSDN...memberChris Maunder13 Jan '02 - 23:33 
GeneralRe: ...or as they tell it in MSDN...memberMathias13 Jan '02 - 23:59 
GeneralRe: ...or as they tell it in MSDN... [modified]memberElmue14 May '12 - 7:09 
AnswerThe perfect solution [modified]memberElmue14 May '12 - 7:20 
GeneralRe: ...or as they tell it in MSDN...sussAnonymous22 Jul '03 - 20:14 
GeneralRe: ...or as they tell it in MSDN...sussAnonymous22 Jul '03 - 20:18 
QuestionHas anyone done this with Visual C++ 6.0?memberSixString29 Nov '01 - 19:47 
AnswerRe: Has anyone done this with Visual C++ 6.0?memberAlbert van Peppen18 Dec '02 - 3:03 
GeneralTop banana!memberBaz3 Apr '01 - 23:16 
QuestionWhat About Console Application?memberAnonymous12 Jan '01 - 12:32 
GeneralJavasussNick20 Jul '00 - 12:48 
QuestionHow do you do this in Delphi?sussRick Ashford13 Apr '00 - 19:01 
QuestionHow to avoid task being removed from task list ( in the Task Manager)?sussBernd Giesen7 Apr '00 - 3:23 
QuestionWorking for Dialog based Apps!! The correct way?sussAlbert van Peppen6 Apr '00 - 2:52 
AnswerRe: Working for Dialog based Apps!! The correct way?sussMartin Schmid16 Apr '00 - 17:57 
AnswerRe: Working for Dialog based Apps!! The correct way?memberAnonymous14 May '01 - 3:05 
AnswerRe: Working for Dialog based Apps!! The correct way?memberWolle4 Aug '01 - 0:21 
GeneralRe: Working for Dialog based Apps!! The correct way?memberWolle4 Aug '01 - 8:30 
AnswerRe: Working for Dialog based Apps!! The correct way?memberRobJones28 Nov '01 - 15:48 
GeneralRe: Working for Dialog based Apps!! The correct way?memberAlbert van Peppen9 Jan '02 - 21:14 
AnswerRe: Working for Dialog based Apps!! The correct way?memberRiccardo Modesti18 Jan '02 - 2:32 
GeneralRe: Working for Dialog based Apps!! The correct way?memberWaleed17 Apr '02 - 13:03 
AnswerRemove WS_EX_APPWINDOW easier. and TOGGLE ...?memberBehzad Ebrahimi17 Dec '02 - 21:46 
GeneralRe: Remove WS_EX_APPWINDOW easier. and TOGGLE ...?sussotwesten14 Apr '03 - 5:12 
AnswerRe: Working for Dialog based Apps!! The correct way?sussAnonymous16 Nov '04 - 18:41 
AnswerRe: Working for Dialog based Apps!! The correct way? - How to fix the ALT+TAB iconmemberDLChambers10 Jan '07 - 7:17 
AnswerRe: Working for Dialog based Apps!! The correct way?memberKienNT787 Mar '08 - 20:22 
GeneralNot totally invisiblesusskabir20 Mar '00 - 4:30 
GeneralRe: Not totally invisiblememberAliAkbar Rashidi2 Apr '01 - 22:52 
GeneralRe: Not totally invisiblememberShengqian Ji19 Apr '02 - 3:33 
GeneralIts far easier to do with dialog Apps !sussColin Davies13 Jan '00 - 9:03 
GeneralRe: Its far easier to do with dialog Apps !sussMartin MacRobert25 Jan '00 - 9:58 
GeneralRe: Need to set 2 properties alsosussVince Buttigieg23 Mar '00 - 13:37 

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

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