Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate

Embed an HTML control in your own window ... [Dll]


  • Please log in to reply
112 replies to this topic
n-l-i-d
  • Guests
  • Last active:
  • Joined: --
You can download the original from here. The cwebpage.dll is in the /dll/example folder.

Here is a repost of my sample code:

#NoEnv 
SetBatchLines, -1 
SetWinDelay, 0 

; Load cwebpage.dll 
cwebpageHandle := DllCall("LoadLibrary", "str", "cwebpage.dll")  

; Exit handler 
OnExit, Cleanup 

; Create menu 
Menu, browserMenu, Add, Back 
Menu, browserMenu, Add, Forward 
Menu, browserMenu, Add, Refresh 
Menu, browserMenu, Add, Stop 
Menu, browserMenu, Add, Home 
Menu, browserMenu, Add, Search 

; Parent window 
Gui, 1: Add, Button, y8 x0 w50 gBack, Back 
Gui, 1: Add, Button, y8 x50 w50 gBack, Forward 
Gui, 1: Add, Button, y8 x100 w50 gRefresh, Refresh 
Gui, 1: Add, Button, y8 x150 w50 gStop, Stop 
Gui, 1: Add, Button, y8 x200 w50 gHome, Home 
Gui, 1: Add, Button, y8 x250 w50 gSearch, Search 
Gui, 1: Add, Button, y370 x0 w150 gGoExample, Open example html 
Gui, 1: Add, Button, y370 x150 w150 gGoAHKCHM, Open AHK chm 
Gui, 1: Add, Button, y370 x300 w150 gGoAHKHome, Go to AHK homepage 
Gui, 1: Show, w600 h400, Internet Explorer container in AHK with cwebpage.dll 
WinGet, mainGuiHandle, ID, A 

; Child window for Browser object 
Gui, 2: Margin, 0, 0 
Gui, 2: +ToolWindow -Caption +Border 
Gui, 2: Show, w590 h320 
WinGet, browserGuiHandle, ID, A 
; Set as child window to main gui 
Gui, 2: +LastFound 
DllCall("SetParent", "uint", WinExist(), "uint", mainGuiHandle) 

; Create the Browser object 
res := DLLCall("cwebpage\EmbedBrowserObject", "uint", browserGuiHandle) 
If (res != 0 Or ErrorLevel != 0) ; error 
  Goto, Cleanup 

; Position the Browser "control" in the Gui 
WinMove, ahk_id %browserGuiHandle%, , 4, 40 

; Load welcome html 
Gosub, GoExample 

; Monitor for right clicks on browser control 
; WM_CONTEXTMENU ; 0x7B 
OnMessage(0x7B, "Web_WM_CONTEXTMENU") 

Return 

; *** Routines: 

; Browser control rightclick 
Web_WM_CONTEXTMENU(wParam, lParam) 
{ 
  Menu, browserMenu, Show 
} 
Return 

; Browser control actions 
Back: 
res := DLLCall("cwebpage\DoPageAction", "uint", browserGuiHandle, "uint", 0) 
Return 

Forward: 
res := DLLCall("cwebpage\DoPageAction", "uint", browserGuiHandle, "uint", 1) 
Return 

Home: 
res := DLLCall("cwebpage\DoPageAction", "uint", browserGuiHandle, "uint", 2) 
Return 

Search: 
res := DLLCall("cwebpage\DoPageAction", "uint", browserGuiHandle, "uint", 3) 
Return 

Refresh: 
res := DLLCall("cwebpage\DoPageAction", "uint", browserGuiHandle, "uint", 4) 
Return 

Stop: 
res := DLLCall("cwebpage\DoPageAction", "uint", browserGuiHandle, "uint", 5) 
Return 

; Examples 

; Load welcome/example html 
GoExample: 
HTML2Load = 
( 
<html><head><title>HTML Template</title></head><body> 
Welcome to the <a href="http://www.codeproject.com/com/cwebpage.asp"> 
cwebpage.dll</a> browser control embedded into an AutoHotkey GUI 
<ol><li>Pressing the <b>Open example html</b> button will load some example html 
<li>Pressing the <b>Open AHK chm</b> button will load the startpage of the AutoHotkey chm helpfile locally on your computer. 
<font color="green"><b>Cwebpage.dll can open and navigate in chm-files too!</b></font> 
<li>Pressing the <b>Go to AHK homepage</b> button will load the AutoHotkey homepage online 
<li>Pressing the <b>Open welcome html</b> button will reload this page</ol> 
You can control the browser object with the top buttons and the context menu... 
 
<font color="red"><b>Enjoy!</b></font>... 
</body></html> 
) 
Gosub, LoadHTML 
Return 

GoAHKCHM: 
URL2Load = its:%A_ProgramFiles%\AutoHotkey\AutoHotkey.chm::docs\AutoHotkey.htm 
Gosub, LoadURL 
Return 

GoAHKHome: 
URL2Load = http://www.autohotkey.com 
Gosub, LoadURL 
Return 

; Load URL 
LoadURL: 
res := DLLCall("cwebpage\DisplayHTMLPage" 
                  , "uint", browserGuiHandle 
                  , "str", URL2Load) 
If (res != 0 Or ErrorLevel != 0) ; error 
  Goto, Cleanup 
URL2Load = 
Return 

; Load HTML 
LoadHTML: 
res := DLLCall("cwebpage\DisplayHTMLStr" 
                  , "uint", browserGuiHandle 
                  , "str", HTML2Load) 
If (res != 0 Or ErrorLevel != 0) ; error 
  Goto, Cleanup 
HTML2Load = 
Return 

; Cleanup and exit 
Cleanup: 
GuiEscape: 
GuiClose: 
DLLCall("cwebpage\UnEmbedBrowserObject", "uint", browserGuiHandle) 
DllCall("FreeLibrary", "uint", cwebpageHandle) 
ExitApp 
Return

You should not use this one, though... Deprecated. Use COM/IE instead.

HTH

daonlyfreez
  • Members
  • 995 posts
  • Last active: Jan 23 2013 08:16 AM
  • Joined: 16 Mar 2005
More mirrors of cwebpage.zip:

- on DropBox
- on AutoHotkey.net
- on daonlyfreez.net

HTH
Posted Image mirror 1mirror 2mirror 3ahk4.me • PM or Posted Image

tacman132
  • Members
  • 9 posts
  • Last active: Jun 20 2010 03:59 PM
  • Joined: 07 Feb 2010
How does this relate to autohotkey

Murx
  • Guests
  • Last active:
  • Joined: --

How does this relate to autohotkey

Why not read the 8 pages of this thread to understand why?

leodahsan
  • Guests
  • Last active:
  • Joined: --
what about add a "loading" icon on down-right side of the window?
or a loading bar? :D
well. only the loading icon is cool...
(sorry for bad english)

garry
  • Spam Officer
  • 3219 posts
  • Last active: Sep 20 2018 02:47 PM
  • Joined: 19 Apr 2005
@ n-l-i-d
navigate buttons don't work in example above ( cwebpage.dll ), (back,forward)

n-l-i-d
  • Guests
  • Last active:
  • Joined: --
@garry.

Apparently the CodeProject file that is available for download (the one I mirrored), is not the same as the one from this project.

It seems the cwebpage.dll is flagged as a virus by many anti-virus programs. The reason why I lost the original.

If you get a hold on the original one (which should include the missing DLLCalls you mentioned), let us know.

Still, it would be better to switch to the COM version instead.

garry
  • Spam Officer
  • 3219 posts
  • Last active: Sep 20 2018 02:47 PM
  • Joined: 19 Apr 2005

If you get a hold on the original one (which should include the missing DLLCalls you mentioned), let us know.

thank you n-l-i-d for answer, I haven't the original cwebpage.dll ( so navigation-buttons not work)