Inno Setup: Embedding web browser in custom wizard page

Simplest way to show web page in Inno Setup custom wizard page is to use ATL Control Hosting API, which allows inserting ActiveX controls (such as IE web browser)  to any window. We need to:

  1. Call AtlAxWinInit()
  2. Call CreateWindowEx with AtlAxWin as class name parameter and ProgID/CLSID/URL as window text parameter.
const WS_CHILD   = $40000000;
      WS_VISIBLE = $10000000;

function AtlAxWinInit(): Boolean; 
external 'AtlAxWinInit@Atl.dll cdecl';

function CreateWindowEx(dwExStyle: Dword; lpClassName, lpWindowName: String; 
                        dwStyle: Dword; x, y, nWidth, nHeight: Integer;
                        hWndParent, hMenu, hInstance: HWND; lpParam: Dword): Integer; 
#ifdef UNICODE
external 'CreateWindowExW@user32.dll stdcall';
external 'CreateWindowExA@user32.dll stdcall';
function DestroyWindow(wnd: HWND): Integer;
external 'DestroyWindow@user32.dll stdcall';

var Browser: HWND;

function CreateCustomForm(PreviousPageId: Integer): Integer;
var Page: TWizardPage;
    Page := CreateCustomPage(PreviousPageId, 'Web Page', 'Wizard page with embedded browser'); 
    Browser := CreateWindowEx(0, 'AtlAxWin', '',
                              WS_CHILD or WS_VISIBLE, 
                              ScaleX(0), ScaleY(0), ScaleX(410), ScaleY(230), 
                              Page.Surface.Handle, 0, 0, 0);
    Result := Page.ID;

procedure InitializeWizard();

procedure DeinitializeSetup();

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s