Hide Application Icon

How to hide App from ALT+TAB but not from the Taskbar (icon row)

  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.

Android hide/unhide app icon programmatically

Hide app's icon using below code:

PackageManager p = getPackageManager();
ComponentName componentName = new ComponentName(this, com.apps.MainActivity.class); // activity which is first time open in manifiest file which is declare as <category android:name="android.intent.category.LAUNCHER" />
p.setComponentEnabledSetting(componentName,PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP);

Here is how to bring back the app's icon.

PackageManager p = getPackageManager();
ComponentName componentName = new ComponentName(this, com.apps.MainActivity.class);
p.setComponentEnabledSetting(componentName, PackageManager.COMPONENT_ENABLED_STATE_ENABLED, PackageManager.DONT_KILL_APP);

Important Edit:

According to docs, as of Android Q (API 29) all app icons will be visible in the launcher no matter what unless:

As of Android Q, at least one of the app's activities or synthesized
activities appears in the returned list unless the app satisfies at
least one of the following conditions:

  • The app is a system app.
  • The app doesn't request any permissions.
  • The tag in the app's manifest doesn't contain any child elements that represent app components.

Additionally, the system hides synthesized activities for some or all
apps in the following enterprise-related cases:

  • If the device is a fully managed device, no synthesized activities for any app appear in the returned list.
  • If the current user has a work profile, no synthesized activities for the user's work apps appear in the returned list.

Hide application icon from task bar

set_skip_pager_hint() is for the Alt-Tab dialog. You want set_skip_taskbar_hint() instead.



Related Topics



Leave a reply



Submit