How to dynamically show/hide the Taskbar application button


Desktop-as-a-Service Designed for Any Cloud ? Nutanix Frame

An issue is to implement the show/hide taskbar application button from within the window-application in Microsoft Visual C++ environment using MFC. Hiding the taskbar can be accomplished by ITaskbarList COM interface which requires necessary COM-handling overhead. Unfortunately, this interface is provided by Shell32.dll version 4.71 (and higher) only. Normally, there is not even a standard header in Microsoft Visual C++ 6.0 supporting this feature. Although the full source code is obtainable in Microsoft MSDN Source Library, the idea was to implement this feature as simple as possible just using the standard WINDOWS functions.

Showing/hiding taskbar buttons normally work in conjunction with registering an application icon in the system tray (adding or removing an icon to the system tray is equally described on other pages).

There is no big problem to implement visual behavior of taskbar buttons while creating the main application window. It does just to set an invisible Popup or Overlapped window as the parent window of the main application window (generally derived from CFrameWnd) in it's PreCreateWindow() virtual method. This solution is well-known and well documented. But how to restore the visibility of the hidden taskbar button again in runtime. Let's figure out:

First Step:

Create the modeless invisible dialog using resource dialog with ID e.g. IDD_FRAMEOWNER (empty dialog with no borders):

BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs) 
    if (!CFrameWnd::PreCreateWindow(cs)) return FALSE; 
    if (!m_bOwnerCreated) // "dialog-is-created" flag 
        // m_MainFrameOwner - CDialog object mapped to the resource dialog template 
        m_bOwnerCreated = m_MainFrameOwner.Create(IDD_FRAMEOWNER); 
        if (m_bOwnerCreated) m_MainFrameOwner.ShowWindow(SW_HIDE); 

    // set the dialog as a parent of CMainFrame window 
    if (m_bOwnerCreated) 
    cs.hwndParent = m_MainFrameOwner.GetSafeHwnd(); 

    return TRUE; 

Last Step

Define the method like this:

BOOL CMainFrame::ShowTaskBarButton(BOOL bVisible) 
    if (!m_bOwnerCreated) return FALSE; 


    if (bVisible) 
        ModifyStyleEx(0, WS_EX_APPWINDOW); 
        ModifyStyleEx(WS_EX_APPWINDOW, 0);


    return TRUE; 

When we need to show the taskbar button that was previously hidden we have to modify the CMainFrame window ex-style by adding WS_EX_APPWINDOW flag. This flag suppresses the behavior of the owner window and the application itself becomes visible (from the taskbar point of view).

On the other hand removing WS_EX_APPWINDOW flag forces the taskbar to find the owner window relying to the CMainFrame window - which is invisible and the button gets disappeared. Using ShowWindow() method is needed to make the necessary refreshing of the taskbar itself after changing the CMainFrame window ex-style.


  • Hammad is very genius Guy Tell Me About System Tray

    Posted by Legacy on 09/16/2003 07:00am

    Originally posted by: Ramzan

    Please tell me how can we develope app in system tray.

  • A method for doing this in CDialog-based apps that Really Works

    Posted by Legacy on 03/11/2003 08:00am

    Originally posted by: Warren Young

    I have an article here on CodeGuru that does the same sort of thing as Filipp's code, but for CDialog-based apps. Filipp's code only seems to work with CWnd-based apps. There are several comments attached to this article try to address this issue, but none of them seem to help.

    My article's URL is http://codeguru.com/shell/tbhide.html

  • Hide Icons of OTHER applications in the SysTray

    Posted by Legacy on 02/02/2003 08:00am

    Originally posted by: jose rizal

    How do you hide the selected icons of OTHER applications in the system tray without terminating them using Visual Basic or VC++?

  • How do you hide a "website's" taskbar button.

    Posted by Legacy on 07/28/2002 07:00am

    Originally posted by: Charles

    Hey there guys and gals. Just found this forum on yahoo as I was doing some research. Ok here it is. I would like to create a webpage that will not have a taskbar button.

    In other words, everytime you open a site, it will appear on your taskbar... right? Well I want know how I can create a "floating" site that does not display itself on the task bar.

    Can this be acheived with simple scripting or do I have to embed the page in some form of application that floats and then hide the application itself. Been racking my brain on this one for a while. I really don't want to have to create a software (which I've never done) to achieve this goal. Your response would be most appreciated.

  • Intertsting

    Posted by Legacy on 02/15/2001 08:00am

    Originally posted by: Ravish.S

    The given article is wonderful and informative.

  • I got it ! A Taiwanese said.

    Posted by Legacy on 12/05/2000 08:00am

    Originally posted by: Powen Ko

    Thank you very much,
    I want find a hide window programming of Visual C++ that spent many days,
    Thank you for you writing this programming.
    Thank you Again.

  • Enhanced solution

    Posted by Legacy on 11/30/2000 08:00am

    Originally posted by: Yair Konfino

    Hi All !

    I made some changes to the ShowTaskBarButton function.
    Use it like this :

    BOOL CMainFrame::ShowTaskBarButton(BOOL bVisible)

    if (bVisible)


    return TRUE;

    Don't forget to set the owner dialog as one with no borders and as a child.

    Look at the MSDN article :
    HOWTO: Prevent a Window from Appearing on the Taskbar.

  • How to put the application in the systray

    Posted by Legacy on 10/31/2000 08:00am

    Originally posted by: Mala

    I want to get the icon for the application directly into the systray when the exe file is executed. I do not require during minimize operation i want to start and stop the application thru the icon similar to other applications like volume control, realplayer, etc.,
    It is a dialog based application.

    Could u please help me.
    Thanks in advance

  • the solution for CDialog-based apps

    Posted by Legacy on 08/31/2000 07:00am

    Originally posted by: Manfred Zinner

    The shell does not create a taskbar button if the window being created has the WS_EX_TOOLWINDOW style. This is well-known, but this trick did not seem to work for Dialog-based apps.

    The problem with Dialog-based apps is that the wizard-generated resource file creates the main dialog with an extended style bit WS_EX_APPWINDOW set. This is not visible / changeable in the resource editor. checking or unchecking 'Tool Window' in the resource editor will toggle between

    ; with both settings a taskbar button will be created.

    To solve this, open the .rc file, selecting 'Open As: Text'
    in the file open dialog box. search for the line


    and replace WS_EX_APPWINDOW with WS_EX_TOOLWINDOW.

    Save, recompile and start - no taskbar button will be created.

  • Taskbar button not pressed when window brought to top

    Posted by Legacy on 08/18/2000 07:00am

    Originally posted by: Christian Carrillo

    I haven't been able to fix this problem.

    When the taskbar button -is displayed- and the window
    is not on top, and you click the window's caption to bring
    it to the top, it comes to the top but its button in the
    taskbar is not pressed.

    It's unclear why the disconnection between the main
    window and the taskbar should cause the taskbar not to
    update. There may not be a way around this problem.
    If anyone has any suggestions, please let me know!

  • Loading, Please Wait ...

  • You must have javascript enabled in order to post comments.

Leave a Comment
  • Your email address will not be published. All fields are required.

Most Popular Programming Stories

More for Developers

RSS Feeds

Thanks for your registration, follow us on our social networks to keep up-to-date