Inno Setup - how to edit the About dialog box

I need to edit or replace text in an About Setup

Inno Setup dialog box.

Here's a picture:

enter image description here

Looking on the internet I got this code:

[Setup]
AppName=My Program
AppVerName=My Program v 1.5
DefaultDirName={pf}\My Program
OutputDir=.

[Languages]
Name: "default"; MessagesFile: "compiler:Default.isl"

[Files]
Source: CallbackCtrl.dll; Flags: dontcopy

[Code]
type
  TWFProc = function(h:hWnd;Msg,wParam,lParam:Longint):Longint;

function CallWindowProc(lpPrevWndFunc: Longint; hWnd: HWND; Msg: UINT; wParam: Longint; lParam: Longint): Longint; external 'CallWindowProcA@user32.dll stdcall';
function SetWindowLong(Wnd: HWnd; Index: Integer; NewLong: Longint): Longint; external 'SetWindowLongA@user32.dll stdcall';
function WrapWFProc(Callback: TWFProc; ParamCount: Integer): Longword; external 'wrapcallbackaddr@files:CallbackCtrl.dll stdcall';

var
  OldProc:Longint;

procedure AboutSetupClick;
begin
  //Edit your text here
  MsgBox('CUSTOM TEXT HERE', mbInformation, MB_OK);
end;

function WFWndProc(h:HWND;Msg,wParam,lParam:Longint):Longint;
begin
  if (Msg=$112) and (wParam=9999) then begin
    Result:=0;
    AboutSetupClick;
  end else begin
    if Msg=$2 then SetWindowLong(WizardForm.Handle,-4,OldProc);
    Result:=CallWindowProc(OldProc,h,Msg,wParam,lParam);
  end;
end;

procedure InitializeWizard;
begin
  OldProc:=SetWindowLong(WizardForm.Handle,-4,WrapWFProc(@WFWndProc,4));
end;

      

Everything seems to be fine.

enter image description here

But if I close the installer, I get an error.

enter image description here

Please, I need help to fix this code or give a better example for changing the text in the text box of the "Settings" dialog.

DLL used. HERE

+3


source to share


1 answer


Before exiting the setup application, you need to return the saved original Windows procedure to the wizard form. To do this, use something like this:

const
  GWL_WNDPROC = -4;

procedure DeinitializeSetup;
begin
  SetWindowLong(WizardForm.Handle, GWL_WNDPROC, OldProc);
end;

      



You can use a more trusted library to wrap the callbacks anyway, the library InnoCallback

. I looked at the code you were using and added support for Unicode InnoSetup versions, expecting the library to be used InnoCallback

:

[Setup]
AppName=My Program
AppVersion=1.5
DefaultDirName={pf}\My Program
OutputDir=userdocs:Inno Setup Examples Output

[Files]
Source: "InnoCallback.dll"; DestDir: "{tmp}"; Flags: dontcopy

[Code]
#ifdef UNICODE
  #define AW "W"
#else
  #define AW "A"
#endif
const
  GWL_WNDPROC = -4;
  SC_ABOUTBOX = 9999;
  WM_SYSCOMMAND = $0112;

type
  WPARAM = UINT_PTR;
  LPARAM = LongInt;
  LRESULT = LongInt;
  TWindowProc = function(hwnd: HWND; uMsg: UINT; wParam: WPARAM; 
    lParam: LPARAM): LRESULT;

function CallWindowProc(lpPrevWndFunc: LongInt; hWnd: HWND; Msg: UINT; 
  wParam: WPARAM; lParam: LPARAM): LRESULT;
  external 'CallWindowProc{#AW}@user32.dll stdcall';  
function SetWindowLong(hWnd: HWND; nIndex: Integer; 
  dwNewLong: LongInt): LongInt;
  external 'SetWindowLong{#AW}@user32.dll stdcall';    
function WrapWindowProc(Callback: TWindowProc; ParamCount: Integer): LongWord;
  external 'wrapcallback@files:InnoCallback.dll stdcall'; 

var
  OldWndProc: LongInt;

procedure ShowAboutBox;
begin
  MsgBox('Hello, I''m your about box!', mbInformation, MB_OK);
end;

function WndProc(hwnd: HWND; uMsg: UINT; wParam: WPARAM; 
  lParam: LPARAM): LRESULT;
begin
  if (uMsg = WM_SYSCOMMAND) and (wParam = SC_ABOUTBOX) then
  begin
    Result := 0;
    ShowAboutBox;
  end
  else
    Result := CallWindowProc(OldWndProc, hwnd, uMsg, wParam, lParam);
end;

procedure InitializeWizard;
begin
  OldWndProc := SetWindowLong(WizardForm.Handle, GWL_WNDPROC, 
    WrapWindowProc(@WndProc, 4));
end;

procedure DeinitializeSetup;
begin
  SetWindowLong(WizardForm.Handle, GWL_WNDPROC, OldWndProc);
end;

      

+7


source







All Articles