Skip to main content
Email Password   helpLost your password?

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.

You must Sign In to use this message board.
 
 
Per page   
 FirstPrevNext
Newssumthing missing Pin
addy808
4:09 23 Apr '07  
GeneralVC++ Code to add application icon to the Task Manager Pin
Smitha Rao
5:03 27 Sep '06  
GeneralRe: VC++ Code to add application icon to the Task Manager Pin
hari_honey
20:53 19 Aug '08  
Questionalt+tab Pin
Anonymous
2:41 12 Sep '05  
AnswerRe: alt+tab Pin
Torres O.
13:26 19 Jan '06  
General[Message Removed] Pin
nompel
10:18 6 Oct '08  
AnswerRe: alt+tab Pin
sam t. xu
11:11 21 Apr '06  
GeneralHow I can add an icon in the left superior corner? Pin
leoncar
19:14 12 Jan '04  
GeneralHow I can add an icon in the left superior corner? Pin
leolim
19:13 12 Jan '04  
GeneralHow to make it in Visual Basic? Pin
Mickey_vip
13:40 6 Aug '03  
Hello
I'm a graduating student with almost no experience in professional programming and I have a question:
How can I make my Visual Basic 6.0 windows application to run and show only as tray icon and not on task bar?

Thank you in advance


mickey
Sign In·View Thread·PermaLink1.33/5
GeneralIncorrect icon in system dialog When Alt+Tab Pin
kimdaejeong
0:31 25 Apr '03  
GeneralHow to Create an application(base dialog) with no taskbar icon? Pin
zhangyifei
4:40 25 Nov '02  
GeneralThis man is just great :) Pin
Anonymous
15:59 27 Mar '02  
General...or as they tell it in MSDN... Pin
Mathias
0:14 14 Jan '02  
GeneralRe: ...or as they tell it in MSDN... Pin
Chris Maunder
0:33 14 Jan '02  
GeneralRe: ...or as they tell it in MSDN... Pin
Mathias
0:59 14 Jan '02  
GeneralRe: ...or as they tell it in MSDN... Pin
Anonymous
21:14 22 Jul '03  
GeneralRe: ...or as they tell it in MSDN... Pin
Anonymous
21:18 22 Jul '03  
GeneralHas anyone done this with Visual C++ 6.0? Pin
SixString
20:47 29 Nov '01  
GeneralRe: Has anyone done this with Visual C++ 6.0? Pin
Albert van Peppen
4:03 18 Dec '02  
GeneralTop banana! Pin
Baz
0:16 4 Apr '01  
GeneralWhat About Console Application? Pin
Anonymous
13:32 12 Jan '01  
GeneralJava Pin
Nick
13:48 20 Jul '00  
GeneralHow do you do this in Delphi? Pin
Rick Ashford
20:01 13 Apr '00  
GeneralHow to avoid task being removed from task list ( in the Task Manager)? Pin
Bernd Giesen
4:23 7 Apr '00  


Last Updated 5 Jan 2000 | Advertise | Privacy | Terms of Use | Copyright © CodeProject, 1999-2009