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.
[Code]
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';
#else
external 'CreateWindowExA@user32.dll stdcall';
#endif
                        
function DestroyWindow(wnd: HWND): Integer;
external 'DestroyWindow@user32.dll stdcall';

var Browser: HWND;

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

procedure InitializeWizard();
begin
    CreateCustomForm(wpWelcome);
end;

procedure DeinitializeSetup();
begin
    DestroyWindow(Browser);
end;
Advertisements

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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