Inno Setup Web page display plugin WebCTRL

Source: Internet
Author: User

Original: Inno Setup Web page display plugin WebCTRL

; --Example.iss--; Restools; http://restools.hanzify.org; Plugin name: Webctrl.dll; Plug-in Features: Network connection detection, create page pages. Plug-in size: 9 KB; V2 Enhanced operation function, you can create up to 256 Web windows at the same time.; The V2 example demonstrates the creation of a small browser to reflect how the functions in this version are used. Rather than V1, it is important to create multiple Web windows at the same time. [Setup] Appname= my program appvername= my program version 1.5defaultdirname={pf}/my program [files]source: "Webctrl.dll"; Flags:dontcopysource: "File.htm"; Flags:dontcopysource: "Wizard.htm"; Flags:dontcopysource: "1.gif"; Flags:dontcopysource: "2.gif"; Flags:dontcopysource: "3.gif"; Flags:dontcopy[code]function GetSystemMetrics (Nindex:integer): Integer; External ' GetSystemMetrics@user32.dll stdcall '; function GetWindowLong (Wnd:hwnd; Index:integer): Longint; External ' GetWindowLongA@user32.dll stdcall '; function SetWindowLong (Wnd:hwnd; Index:integer; Newlong:longint): Longint; External ' SetWindowLongA@user32.dll stdcall ';/////////////////////////////////////////////////////////////////// Check the network connection is normal//lpszurl: URL, if this is set to empty URL, detection will be simple check network status, return status flag//lpdwstate: status Flag, the following is the explanation of the flag value// Note: When you do not use URLs to detect networksWhen connecting, just check whether the current compliance with the conditions of the network connection, but does not equal//can connect to the Internet normally, but this detection method is quite rapid, if the use of URL connection test, if the network/link is in normal connection, check speed is quite fast, but if not normal, then there will be a little time Delay, because//for the actual connection test there is a timeout limit to determine whether the connection can be connected. However, this detection method is the most direct//, and can really know whether to connect the network, so you follow the actual requirements to choose the detection method. The resulting lpdwstate return value may be the sum of one or more values of the following values://internet_state_connected: $00000001 connection status;//INTERNET_STATE_DISCONNECTE D: $00000002 non-connected status (and internet_state_connected);//internet_state_disconnected_by_user:$00000010 user requested non-connected state//I Nternet_state_idle: $00000100 connection status, and idle//internet_state_busy: $00000200 connection Status, responding to connection request FUNCT Ion Checkconnectstate (Lpsurl:pchar; var lpdwstate:dword): boolean; External ' checkconnectstate@files:webctrl.dll stdcall ';//Initialize WebCTRL plug-in function Initwebctrl (): Boolean; External ' initwebctrl@files:webctrl.dll stdcall ';//release WebCTRL plug-in function Uninitwebctrl (): Boolean; External ' uninitwebctrl@files:webctrl.dll stdcall ';//Create WEB window function Newwebwnd (hwndparent:hwnd; X, Y, nwidth, Nheight:integer): HWND; ExterNal ' Newwebwnd@files:webctrl.dll stdcall ';//Release WEB window function Freewebwnd (hwndweb:hwnd): Boolean; External ' freewebwnd@files:webctrl.dll stdcall ';//Set the parent window of the WEB window function webwndsetparent (hwndweb:hwnd; hwndparent: HWND): Boolean; External ' webwndsetparent@files:webctrl.dll stdcall ';//Set the location size of the WEB window function webwndsetbounds (hwndweb:hwnd; X, Y, nwidth, Nheight:integer): Boolean; External ' webwndsetbounds@files:webctrl.dll stdcall ';//Display HTML page function displayhtmlpage (hwndweb:hwnd; Lpsurl:pchar ): Boolean; External ' displayhtmlpage@files:webctrl.dll stdcall '; ;//Display HTML string function displayhtmlstr (Hwndweb:hwnd; lpshtmltext:pchar): Boolean; External ' displayhtmlstr@files:webctrl.dll stdcall ';//Web page action function webpageaction (Hwndweb:hwnd; action:dword): Boolean; External ' webpageaction@files:webctrl.dll stdcall '; const Sm_cxscreen = 0; Sm_cyscreen = 1; Ws_ex_clientedge = $; Gwl_exstyle =-20; Webpage_goback = 0; Webpage_goforward = 1; Webpage_gohome = 2; webpage_sEarch = 3; Webpage_refresh = 4; Webpage_stop = 5;var urlpage, htmlpage, htmltextpage:twizardpage; WebHWND1, WebHWND2, WebHWND3, Webhwnd4:hwnd; Webhwnd_browser:hwnd; Form_browser:tform; Addredit:tnewedit; Gobtn:tnewbutton;function Initializesetup (): Boolean;begin Initwebctrl (); WebHWND1: = 0; WebHWND2: = 0; WebHWND3: = 0; WebHWND4: = 0; Result: = True;end;procedure deinitializesetup (); Begin Uninitwebctrl (); End;procedure Gobackbtnonclick (Sender: TObject); Begin Webpageaction (Webhwnd_browser, webpage_goback); End;procedure Goforwardbtnonclick (Sender:tobject); Begin Webpageaction (Webhwnd_browser, Webpage_goforward); End;procedure Stopbtnonclick (sender:tobject); begin Webpageaction (Webhwnd_browser, webpage_stop); End;procedure Refreshbtnonclick (sender:tobject); Begin WebPageAction ( Webhwnd_browser, Webpage_refresh); End;procedure Homebtnonclick (sender:tobject); Begin Webpageaction (WebHWND_ Browser, webpage_gohome); End;procedure Gobtnonclick (sender:tobject); Begin DisplayHtmlPage (Webhwnd_browser, addredit.text); End;procedure browserformresize (Sender:tobject); var w:integer;begin Webwndsetbounds (webhwnd_browser, 0, ScaleY (+), Form_browser.clientwidth, Form_browser.clientheight-scaley (35)); W: = Form_browser.width-scalex (285); If w <= 0 then W: = 1; Addredit.width: = W; Gobtn.setbounds (addredit.left + addredit.width + ScaleX (2), ScaleY (5), ScaleX (+), WizardForm.CancelButton.Height); E Nd;procedure editkeypress (Sender:tobject; var key:char); begin if Key = #13 then Displayhtmlpage (Webhwnd_browser, ADD Redit.text); end;procedure Wizardbtnonclick (Sender:tobject); var screenwidth, Screenheight:integer; Btn:tnewbutton;begin Form_browser: = Tform.create (Wizardform); Try form_browser.caption: = ' thinbrowser '; Form_browser.bordericons: = [Bisystemmenu, bimaximize]; ScreenWidth: = GetSystemMetrics (Sm_cxscreen); ScreenHeight: = GetSystemMetrics (Sm_cyscreen); Form_browser.setbounds ((Screenwidth-scalex ()) div2, (Screenheight-scaley) Div 2, ScaleX (+), ScaleY (400)); Webhwnd_browser: = Newwebwnd (form_browser.handle, 0, 0, form_browser.clientwidth, form_browser.clientheight); SetWindowLong (Form_browser.handle, Gwl_exstyle, GetWindowLong (Webhwnd_browser, Gwl_exstyle) or WS_EX_CLIENTEDGE); Btn: = Tnewbutton.create (Form_browser); Btn.setbounds (ScaleX (5), ScaleY (5), ScaleX (+), WizardForm.CancelButton.Height); Btn.caption: = ' &back '; Btn.onclick: = @GoBackBtnOnClick; Btn.parent: = Form_browser; Btn: = Tnewbutton.create (Form_browser); Btn.setbounds (ScaleX), ScaleY (5), ScaleX (n), WizardForm.CancelButton.Height); Btn.caption: = ' &forward '; Btn.onclick: = @GoForwardBtnOnClick; Btn.parent: = Form_browser; Btn: = Tnewbutton.create (Form_browser); Btn.setbounds (ScaleX (104), ScaleY (5), ScaleX (+), WizardForm.CancelButton.Height); Btn.caption: = ' &stop '; Btn.onclick: = @StopBtnOnClick; Btn.parent: =Form_browser; Btn: = Tnewbutton.create (Form_browser); Btn.setbounds (ScaleX (146), ScaleY (5), ScaleX (+), WizardForm.CancelButton.Height); Btn.caption: = ' &refresh '; Btn.onclick: = @RefreshBtnOnClick; Btn.parent: = Form_browser; Btn: = Tnewbutton.create (Form_browser); Btn.setbounds (ScaleX (198), ScaleY (5), ScaleX (+), WizardForm.CancelButton.Height); Btn.caption: = ' &home '; Btn.onclick: = @HomeBtnOnClick; Btn.parent: = Form_browser; Addredit: = Tnewedit.create (Form_browser); Addredit.left: = ScaleX (240); Addredit.top: = ScaleY (6); Addredit.parent: = Form_browser; Addredit.text: = ' About:blank '; Addredit.onkeypress: = @EditKeyPress; GOBTN: = Tnewbutton.create (Form_browser); Gobtn.caption: = ' &go '; Gobtn.onclick: = @GoBtnOnClick; Gobtn.parent: = Form_browser; Browserformresize (Form_browser); Form_browser.onresize: = @BrowserFormResize; Form_browser.activecontrol: = Addredit; Form_browser.showmodal (); FreeWebwnd (Webhwnd_browser); finally Form_browser.free (); End;end;procedure Initializewizard (); var State:dword; s:string; Browserbtn:tnewbutton;begin state: = 0; s: = ';//If a URL connection test is required, uncomment the following code//s: = ' http://www.google.cn '; If Checkconnectstate (S, state) then MsgBox (' network is already connected. ', mbinformation, MB_OK) Else MsgBox (' network not connected. ', Mbcriticalerror, MB_OK); MsgBox (IntToStr (state), mbinformation, MB_OK); Extracttemporaryfile (' wizard.htm '); Extracttemporaryfile (' file.htm '); Extracttemporaryfile (' 1.gif '); Extracttemporaryfile (' 2.gif '); Extracttemporaryfile (' 3.gif '); WebHWND1: = Newwebwnd (WizardForm.WelcomePage.Handle, 0, 0, WizardForm.WizardBitmapImage.Width, WizardForm.WelcomePage.Height); Displayhtmlpage (WebHWND1, Expandconstant (' {tmp}/wizard.htm ')); Urlpage: = CreateCustomPage (wpwelcome, ' Test Web page ', ' URL: http://www.google.cn '); HtmlPage: = CreateCustomPage (urlpage.id, ' Test HTML file page ', ' File: file.htm '); Htmltextpage: = CreateCustomPage (htmlpage.id, ' Test HTML text page ', ' ProCustom HTML string '); BROWSERBTN: = Tnewbutton.create (Wizardform); Browserbtn.left: = Wizardform.clientwidth-wizardform.cancelbutton.left-wizardform.cancelbutton.width; Browserbtn.top: = WizardForm.CancelButton.Top; Browserbtn.width: = WizardForm.CancelButton.Width; Browserbtn.height: = WizardForm.CancelButton.Height; Browserbtn.caption: = ' &browser ... '; Browserbtn.onclick: = @WizardBtnOnClick; Browserbtn.parent: = Wizardform;end;procedure curpagechanged (curpageid:integer); begin if Curpageid = WpWelcome then W Ebwndsetparent (WebHWND1, WizardForm.WelcomePage.Handle) Else if Curpageid = Wpfinished then Webwndsetparent (WebHWND1, WizardForm.FinishedPage.Handle) Else if (Curpageid = urlpage.id) and (WebHWND2 = 0) THEN BEGIN WebHWND2: = Newwebwn D (UrlPage.Surface.Handle, 0, 0, UrlPage.Surface.Width, UrlPage.Surface.Height); Displayhtmlpage (WebHWND2, ' http://www.google.cn ') end else if (Curpageid = htmlpage.id) and (WebHWND3 = 0) THEN BEGIN WebHWND3: = NewwebWnd (HtmlPage.Surface.Handle, 0, 0, HtmlPage.Surface.Width, HtmlPage.Surface.Height); Displayhtmlpage (WebHWND3, Expandconstant (' {tmp}/file.htm ')); End else if (Curpageid = htmltextpage.id) and (WebHWND4 = 0) THEN BEGIN WebHWND4: = Newwebwnd (htmltextpage.surface.h Andle, 0, 0, HtmlTextPage.Surface.Width, HtmlTextPage.Surface.Height); Displayhtmlstr (WebHWND4, ' <b>i ' m a <u>html text</u></b> '); End;end;

Figures:


Download WebCTRL

Inno Setup Web page display plugin WebCTRL

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.