View Single Post
  #7  
Old 20-10-2021, 15:57
Cesar82's Avatar
Cesar82 Cesar82 is offline
Registered User
 
Join Date: May 2011
Location: Brazil
Posts: 1,077
Thanks: 1,826
Thanked 2,310 Times in 789 Posts
Cesar82 is on a distinguished road
I would like to know if anyone has a solution to my problem. I would like to display the thumbnail in the taskbar and at the same time include a checkbox to keep the installer window on top (over other windows) if the checkbox is checked. If I use the code from the page below to display the installer thumbnail on the taskbar the property "WizardForm.FormStyle" doesn't work.
Part of the code was obtained from: inno-setup-window-preview-in-taskbar

If anyone can help me, I appreciate it.
Below is a code to better understand my question.
Code:
[Setup]
AppName=My App
AppVersion=1.0
DefaultDirName={{#VER > 0x06000000 ? "common" : ""}pf}\My App
DisableWelcomePage=no
OutputBaseFilename=My_App
OutputDir=.

[ code]
const
  GW_OWNER = 4;
  GWL_HWNDPARENT = (-8);

function GetWindowLong(Wnd: HWND; nIndex: Integer): Longint; external '[email protected] stdcall delayload';
function SetWindowLong(Wnd: HWND; nIndex: Integer; dwNewLong: Longint): Longint; external '[email protected] stdcall delayload';
function GetWindow(hWnd: HWND; uCmd: UINT): HWND; external '[email protected] stdcall delayload';

var
  OnTopCheckBox: TNewCheckBox;
  ////OldParent: Longint;

procedure OnTopCheckBox_OnClick(Sender: TObject);
begin
  if OnTopCheckBox.Checked then
  begin
    ////SetWindowLong(WizardForm.Handle, GWL_HWNDPARENT, OldParent);
    WizardForm.FormStyle := fsStayOnTop;
  end else
  begin
    WizardForm.FormStyle := fsNormal;
    ////SetWindowLong(WizardForm.Handle, GWL_HWNDPARENT, GetWindowLong(GetWindow(WizardForm.Handle, GW_OWNER), GWL_HWNDPARENT));
  end;
end;

procedure InitializeWizard();
begin
  ////OldParent := GetWindowLong(WizardForm.Handle, GWL_HWNDPARENT);

  OnTopCheckBox := TNewCheckBox.Create(WizardForm);
  with OnTopCheckBox do begin
    Parent := WizardForm;
    Caption := 'Keep On Top';
    SetBounds(ScaleX(10), WizardForm.NextButton.Top + ScaleY(2), ScaleX(100), ScaleX(15));
    OnClick := @OnTopCheckBox_OnClick;
  end;

  { work if disable this line }
  SetWindowLong(WizardForm.Handle, GWL_HWNDPARENT, GetWindowLong(GetWindow(WizardForm.Handle, GW_OWNER), GWL_HWNDPARENT));
end;
Reply With Quote