Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win


How to hide an application from Alt-Tab?

Posted on 1997-12-15
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?
Question by:tflai
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 2
  • 2
  • +4
LVL 23

Expert Comment

ID: 1409574
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?
LVL 11

Expert Comment

ID: 1409575


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;


Author Comment

ID: 1409576
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.
Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments


Expert Comment

ID: 1409577
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.

Author Comment

ID: 1409578
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.

Expert Comment

ID: 1409579
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.

Expert Comment

ID: 1409580
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.

Author Comment

ID: 1409581
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?
LVL 11

Expert Comment

ID: 1409582
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.


Author Comment

ID: 1409583
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...

Expert Comment

ID: 1409584
hi there,

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

i have the answer. (for Win 95).

Author Comment

ID: 1409585
Ok, ahalya, I'm all ear if you've got the answer.

Accepted Solution

ahalya earned 300 total points
ID: 1409586
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 !

Featured Post

NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

zlib is a free compression library (a DLL) on which the popular gzip utility is built.  In this article, we'll see how to use the zlib functions to compress and decompress data in memory; that is, without needing to use a temporary file.  We'll be c…
Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Loops Section Overview

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question