Click here to Skip to main content
6,633,937 members and growing! (21,738 online)
Email Password   helpLost your password?
Desktop Development » Document / View » General     Beginner License: The Code Project Open License (CPOL)

Creating an application with no taskbar icon

By Chris Maunder

A simple method to create a main window that does not appear in the windows taskbar
VC6, Visual Studio, MFC, Dev
Posted:5 Jan 2000
Views:194,743
Bookmarked:48 times
Announcements
Loading...
 
Search    
Advanced Search
Add to IE Search
printPrint   add Share
      Discuss Discuss   Broken Article?Report  
45 votes for this article.
Popularity: 6.99 Rating: 4.23 out of 5
1 vote, 5.9%
1

2
1 vote, 5.9%
3
5 votes, 29.4%
4
10 votes, 58.8%
5

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


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.
Occupation: Founder
Company: The Code Project
Location: Canada Canada

Other popular Document / View articles:

Article Top
You must Sign In to use this message board.
FAQ FAQ 
 
Noise Tolerance  Layout  Per page   
 Msgs 1 to 25 of 52 (Total in Forum: 52) (Refresh)FirstPrevNext
Newssumthing missing Pinmemberaddy8084:09 23 Apr '07  
GeneralVC++ Code to add application icon to the Task Manager PinmemberSmitha Rao5:03 27 Sep '06  
GeneralRe: VC++ Code to add application icon to the Task Manager Pinmemberhari_honey20:53 19 Aug '08  
Questionalt+tab PinsussAnonymous2:41 12 Sep '05  
AnswerRe: alt+tab PinmemberTorres O.13:26 19 Jan '06  
General[Message Removed] Pinmembernompel10:18 6 Oct '08  
AnswerRe: alt+tab Pinmembersam t. xu11:11 21 Apr '06  
GeneralHow I can add an icon in the left superior corner? Pinsussleoncar19:14 12 Jan '04  
GeneralHow I can add an icon in the left superior corner? Pinmemberleolim19:13 12 Jan '04  
GeneralHow to make it in Visual Basic? PinmemberMickey_vip13:40 6 Aug '03  
GeneralIncorrect icon in system dialog When Alt+Tab Pinsusskimdaejeong0:31 25 Apr '03  
GeneralHow to Create an application(base dialog) with no taskbar icon? Pinmemberzhangyifei4:40 25 Nov '02  
GeneralThis man is just great :) PinmemberAnonymous15:59 27 Mar '02  
General...or as they tell it in MSDN... PinmemberMathias0:14 14 Jan '02  
GeneralRe: ...or as they tell it in MSDN... PinmemberChris Maunder0:33 14 Jan '02  
GeneralRe: ...or as they tell it in MSDN... PinmemberMathias0:59 14 Jan '02  
GeneralRe: ...or as they tell it in MSDN... PinsussAnonymous21:14 22 Jul '03  
GeneralRe: ...or as they tell it in MSDN... PinsussAnonymous21:18 22 Jul '03  
GeneralHas anyone done this with Visual C++ 6.0? PinmemberSixString20:47 29 Nov '01  
GeneralRe: Has anyone done this with Visual C++ 6.0? PinmemberAlbert van Peppen4:03 18 Dec '02  
GeneralTop banana! PinmemberBaz0:16 4 Apr '01  
GeneralWhat About Console Application? PinmemberAnonymous13:32 12 Jan '01  
GeneralJava PinsussNick13:48 20 Jul '00  
GeneralHow do you do this in Delphi? PinsussRick Ashford20:01 13 Apr '00  
GeneralHow to avoid task being removed from task list ( in the Task Manager)? PinsussBernd Giesen4:23 7 Apr '00  

General General    News News    Question Question    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

PermaLink | Privacy | Terms of Use
Last Updated: 5 Jan 2000
Editor: Chris Maunder
Copyright 2000 by Chris Maunder
Everything else Copyright © CodeProject, 1999-2009
Web21 | Advertise on the Code Project