We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you a podcast all about Citrix Workspace, moving to the cloud, and analytics & intelligence. Episode 2 coming soon!Listen Now


How to hide an application from Alt-Tab?

tflai asked
Medium Priority
Last Modified: 2013-12-03
I've be able to remove my application from the task bar, without resorting to use WS_EX_TOOLWINDOW (which would make my window looks extremely crappy, without system menu, icon, and minimize/maximize).  (The application would provide UI through the system tray icon.)  But the problem is that it still left in the selection on Alt-Tab.  Is there anyway to remove it from Alt-Tab?
Watch Question

How to prevent Alt-Tab has been asked several times on this topic area. The answer is that you cannot disable it in Windows 95 and Windows NT. For a system tray application, why don't you hide it and show it when it is activated?



Chesnu seemes to misunderstand the question.

Take a look at this bit of code.  I've copied it from one of my programs.  Doesn't show on ALT-TAB

(The spacing will probably be botched.)

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
      WNDCLASS            wc            = { 0 };
      NOTIFYICONDATA      nid            = { sizeof(NOTIFYICONDATA) };
      HWND                  hwnd;


      // Register the window class for the application main window
      wc.style             = CS_HREDRAW | CS_VREDRAW;            // Class style(s)
      wc.lpfnWndProc       = (WNDPROC) WindowProc;            // Window Procedure
      wc.hInstance       = hInstance;                              // Owner of this class
      wc.lpszMenuName  = MAKEINTRESOURCE(IDR_MENU);      // Menu
      wc.lpszClassName = APP_NAME;                              // Name to register as

      if (!RegisterClass(&wc))
            return 0;

      // Create a main window for this application instance.
      hwnd = CreateWindow(APP_NAME, APP_NAME,                              // Class and title
                                    WS_OVERLAPPEDWINDOW,                        // Window style
                                    CW_USEDEFAULT, 0,                              // Use default positioning
                                    CW_USEDEFAULT, 0,                              // Use default size
                                    NULL, NULL,                                          // No parent, no menu
                                    hInstance,                                          // This instance owns this window
                                    NULL);                                                // Don't need data in WM_CREATE
      if (!hwnd)
            return 0;

      // Link with tray icon
      nid.hWnd = hwnd;
      nid.uID = IDI_TRAYICON;
      nid.uFlags = NIF_MESSAGE | NIF_ICON | NIF_TIP;
      nid.uCallbackMessage = MYWM_NOTIFYICON;
      nid.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_TRAYICON));
      lstrcpy(nid.szTip, APP_NAME);

      if (!Shell_NotifyIcon(NIM_ADD, &nid))
            return 0;


Hmm...  I've tried alexo's approach, and doesn't seems to work.  Am I missing something?  Actually, I've a MFC dialog-based application that also create a system tray icon and notification.  So, the icon notification basically just does show/close the main dialog window (left-double click or right-click to show pop-up menu).  It's this dialog box that I can't seem to get ride of in Alt-Tab.  I did forcefully remove it from the taskbar after Windows create it in the taskbar.  I know that by making the dialog window WS_EX_TOOLWINDOW, it will disappear, but I don't want to do that.

Create a window but do not show it.  Make it the parent of the window you want to not appear in the alt-tab or tray (ie: create your main window as a child of the dummy window just described).  Your main window is not WS_CHILD, but has a parent, and is therefore owned and will not appear on the tray or in the alt-tab list.


Sorry to reject the answer.  But I just couldn't duplicate what alexo
and plummer were talking about.  If you could, can you e-mail me
a simplified version of how to hide application from Alt-Tab on
a MFC dialog-based application.  (Actually I do have source code
for hidding a MDI-based application, but it didn't work when I tried
to duplicate what it is doing to MainFrame as to my main
DialogBox.)  Also, I've found out that even
if I made the main window WS_EX_TOOLWINDOW, any
subsequent pop-up modal dialog boxes will shows up itself in
both taskbar and Alt-Tab.

What's wrong with letting the dialog appear in the task bar? Take the volume control, for example. Normally it's sitting there innocently on the task bar with its window (dialog) completely hidden. But, when clicked the window pops up and appears in the task bar becoming a fully functional app.

To me this behaviour would be more desirable.

OK, when you want to hide a window from task bar you make it a popup window with an invisible owner (i.e. create a hidden main window (overlapped) and create a modeless dialog with that main window as an owner). But I agree with Melange: when you only have an icon, hide the dialog, it will not appear on the task bar. And when the dialog is activated, you really want it to be on the task bar.


Okay, then, I'll just leave it on the taskbar.  Thanks.  Hmm....  How do I resolve the problem of giving grade away?  Who get the point?

Who do you want to give the points to?
Ask a specifig person to submit an answer and grade it.

If you want to split the points between several persons, just enter some dummy questions titled "for <name>".

You can also ask the admins to cancel the question and refund the points since you didn't get the answer.

However, it's a shame to leave the question unanswerd.
Since you're using MFC, try to check the MFC sources to see whether it does things behind the scenes that might interfere with your goal.

Check the window style, maybe it will work if you change it.  However, see the help file topic "FAQ: Changing the Styles of a Window Created by MFC".

Maybe you'll need to hide the window (or to disable it) after creation.

Also, you can ask a zero-points question in the MFC area, in which you point to this question.  Something like "Please answer my question in another area" and in the body give the question name, number and URL.

Best of luck.


Well, I've decided to withdraw this question and save my points for
tougher questions in the future, :-)  Thanks for everyone's help, but
I can't reallyjudge how to distribute the points if I wanted to do that...

hi there,

if you're still interested in an answer then let me know.

i have the answer. (for Win 95).


Ok, ahalya, I'm all ear if you've got the answer.
OK. Here i open my mind  !

You have to use the "RegisterServiceProcess" function to pretend that your prog is a service (yeah, kind of) in Win 95.


function RegisterServiceProcess (ThreadID:THandle;Flags:Integer):
Integer; stdcall; external kernel32 name 'RegisterServiceProcess';

Usage: {say in your formcreate event}
const      RSP_SIMPLE_SERVICE = 1;

ok := RegisterServiceProcess (0, RSP_SIMPLE_SERVICE);
if ok  = 0 then ShowMessage ('Error Registering Service');

As you'd figure out a "side effect" of calling RSP is that you program will not appear in the task list anymore ! (isn't that nice !)

yeah, you can pass RSP_UNREGISTER_SERVICE and make your app a regular one at any time !

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.