Dragodraki
Dragodraki

Reputation: 53

Inno Setup: How can I hide the wizards taskbar icon?

Introduction:
Inno Setup helps me in creating wizards and automated patches for several years now and I am really happy with that compiler. There is barely anything you cannot do with it and the code seems much easier to understand to me than from others (e.g. NSIS, Delphi, etc.).

Question:
What is the code for hiding the entire taskbar icon in Inno Setup 5.x (not just empty icon)?

Background info:
I am well aware that for standard installers this is not needed and would look suspicious. But I talk about those wizards who are part of a bigger installer (they need to have their own due to the way Windows handles environment variables and user group permissions) - imagine it like a container in a container. The outer one is displayed normally, but the inner one should be run "verysilent" even when the user uses it by double-clicking later (most of you already faced this by installing apps as it's not uncommon behaviour). I already managed to hide the setup window by using WizardForm.Hide - but that leaves me without window but still with taskbar icon (looks as unprofessional as a flashing console window on a client would).

What I tried already:

What I know so far:

Upvotes: 0

Views: 185

Answers (1)

Konstantin Makarov
Konstantin Makarov

Reputation: 1376

I checked this code on Inno Setup Compiler 6.2.2. It hides the icon from the taskbar. The only note is that the icon appears along with the Message Box showing, for example, "Choosing the installation language".

    [Code]
    var
      function ShowWindow(hWnd: Integer; uType: Integer): Integer;
      external '[email protected] stdcall delayload';

      function GetWindowLong(hWnd, nIndex: Integer): Longint;
      external 'GetWindowLongW@user32 stdcall delayload';
    
      function SetWindowLong(hWnd: HWND; nIndex: Integer; dwNewLong: Longint): Longint;
      external '[email protected] stdcall delayload';

    const
      GWL_HWNDPARENT = (-8);
      GWL_EXSTYLE = (-20);
      WS_EX_TOOLWINDOW = $80;
        
    procedure InitializeWizard();
    var
      hWindow: HWND;

    begin
      hWindow := GetWindowLong(MainForm.Handle, GWL_HWNDPARENT);
      SetWindowLong(hWindow, GWL_EXSTYLE, GetWindowLong(hWindow, GWL_EXSTYLE) or WS_EX_TOOLWINDOW);
      ShowWindow(hWindow, SW_HIDE);
      //CreateCustomPages;
    end;

Upvotes: 1

Related Questions