Home > Mobile >  How to hide App from ALT TAB but not from the Taskbar (icon row)
How to hide App from ALT TAB but not from the Taskbar (icon row)

Time:02-24

I want to hide my App from ALT TAB but not from the Taskbar; The taskbar has a icon now OK that can be used to manage the tool GUI.

However, there is no need to have the app in ALT-TAB browsable window list as the main window of app is actually hidden.

The App Window is hidden by setting its ALPHA to 0.

CodePudding user response:

  1. You have to set your Form.BorderStyle to either bsSizeToolWin or bsToolWindow, so its window is not listed in the Alt Tab dialog.
  2. You have to do the same for the Application.Handle window:
    procedure TForm1.FormCreate( Sender: TObject );
    var
      iStyle: Integer;
    begin
      iStyle:= GetWindowLong( Application.Handle, GWL_EXSTYLE );
      SetWindowLong( Application.Handle, GWL_EXSTYLE, iStyle or WS_EX_TOOLWINDOW );
    end;
    
    Steps #1 and #2 work for me as expected: nothing in the window list, not one button on the taskbar.
  3. As per Remy to add a taskbar button alone the interface promises to do so:
    uses
      ComObj;
    
    // From https://github.com/project-jedi/jvcl/blob/master/jvcl/run/JvProgressBar.pas
    const
      CLSID_TaskbarList: TGUID= '{56FDF344-FD6D-11d0-958A-006097C9A090}';
    
    type
      ITaskbarList= interface(IUnknown)
        ['{56FDF342-FD6D-11D0-958A-006097C9A090}']
        function HrInit: HRESULT; stdcall;
        function AddTab( hwnd: HWND ): HRESULT; stdcall;
        function DeleteTab( hwnd: HWND ): HRESULT; stdcall;
        function ActivateTab( hwnd: HWND ): HRESULT; stdcall;
        function SetActiveAlt( hwnd: HWND ): HRESULT; stdcall;
      end;
    
    var
      oBar: ITaskbarList= nil;
    
    procedure TForm1.Button1Click( Sender: TObject );
    begin
      if oBar= nil then begin  // Never used? Try to init.
        oBar:= CreateComObject( CLSID_TaskbarList ) as ITaskbarList;
        if oBar.HrInit<> S_OK then oBar:= nil;  // Failed? Can't use it.
      end;
      if oBar<> nil then begin
        if oBar.AddTab( self.Handle )= S_OK then self.Caption:= 'Success!';
      end;
    end;
    
    However: this 3rd step didn't work for me on Win7 - no button was added to the taskbar, although no error occurred. It may be because
    • I have disabled styles and my taskbar looks like in Win95, and
    • T-Clock Redux 2.4.4 is manipulating it.

I discourage this entire approach: what appears in Alt Tab should also have a taskbar button and vice versa. At work there's this annoying NCP software which auto hides its window upon successful connect, insists on using a tasktray icon and auto-slides in a window as soon as I come near the taskicon, although I surely wanted to hit a different one. Horrible, because it's always in the way and can't be relied on to persist either.

That's not what you intend, but you also want to force inconsistency. Simply don't. Just release an application that can be used and where expected behavior also happens. If all that doesn't move you then think of how prone your application will be in the future to fail in emulations - don't do unusual stuff and Wine will have no problems running it for all Unix users, too.

  • Related