I've been a bit quiet because I have been working on using a WebBrowser control in an assembler application.
The COM interface IWebBrowser2 can be used to control the WebBrowser control. It can be created easily using QueryInterface. However, by itself it doesn't work. You have to create the WebBrowser control using the API OleCreate. That API requires the interface IStorage to be passed to it, and also three other interfaces all of which need to be established by the application. You need to provide functions within these interfaces for the system to call when it wants information from the application.
The attached zip file WebSkel.zip contains all source and an exe (with debug symbols) demonstrating this functionality.
I am indebted to Jeff Glatt's who wrote Display a web page in a plain C Win32 application (http://www.codeguru.com/cpp/i-n/ieprogram) and Chris Becke who provided a C++ sample in his file webhost.cab (http://www.mvps.org/user32/).
[attachment deleted by admin]
thank you dear Auther!I had found this for 2 days. :clap: :clap:
Excellent! Thank you. :U
seems that SDK don't agree with such a hard work.A proc is enough.
Just invoke OleInitialize before the call of:
http://www.masm32.com/board/index.php?topic=10864.msg79597#msg79597
There are a few ways to implement the IWebBrowser interface, I have been experimenting with several this week, probably the simplest is the use of an Atl container template (http://msdn.microsoft.com/en-us/library/3ax346b7(VS.80).aspx). It's very easy to use and can be used as a container for just about any class of COM object, hard to beat for simplicity.
See the sample project below
Hello,
I have made a little test (in masm) with your code.
I saw that the main window hMainWnd is not defined in you code,so i made my main window like that.
Quote
invoke GetModuleHandle, NULL
mov hInstance,eax
invoke SearchAdresse,SADR("atl.dll"),addr Hlibrairie,addr ADRAtlAxDialogBoxW
invoke AtlAxWinInit
.if eax == 0
jmp FindeThread
.endif
; Create the window with a URL, this will initialize the container for IWebBrowser2
invoke CreateWindowEx,NULL,SADR("AtlAxWin"),SADR("ms-help://MS.LHSMSSDK.1033/sdkintro/html/4778d9b3-e4a3-4d7b-b790-20a3c9dbab6f.htm"),\
WS_EX_OVERLAPPEDWINDOW + WS_VISIBLE,0,0,300,300,NULL,NULL,hInstance,NULL
mov hAtl,eax
INVOKE ShowWindow,hAtl, SW_SHOWNORMAL
INVOKE UpdateWindow,hAtl
invoke BoucleAttente ;waiting loop
jmp FindeThread
There is no wrappers and no call to the IWebBrowser2 interface.
I launch it and ... it's work without all that.
I have a window with the html file that can be browse
BUT without systems button and the window couldn't be quit without the help of another window.
Here are two files to use ATL with masm.
[attachment deleted by admin]
Hi ToutEnMasm,
Yes, I know you can call it without wrappers but how do you change the page being displayed ? You will eventually have to call IWebBrowser2, if for nothing else than to call the Quit method in order to close the object. The ATL container that I used is a child of a main window, you will run into some problems if you try to make the container a main window without implementing the DWebBrowserEvents2 sink. Without that sink the web browser has no way to communicate event triggers back to your program. For MFC objects like ATL you need to call the AfxConnectionAdvise / AfxConnectionUnadvise helper functions and implement the DWebBrowserEvents2 interface in your code, specifically IUnknown and IDispatch. I have great hopes since I can get the pointer to the IOleObject and IDataObject interfaces which might allow me to implement the event sink, that's for the weekend though.
Quote
Yes, I know you can call it without wrappers but how do you change the page being displayed ?
Just clic on the links in the web page.
Surely I have been a little fast to do it.
I have mixed styles in the createwindows fonction.Correct are:
Quote
invoke CreateWindowEx,WS_EX_OVERLAPPEDWINDOW,SADR("AtlAxWin"),SADR("ms-help://MS.LHSMSSDK.1033/sdkintro/html/4778d9b3-e4a3-4d7b-b790-20a3c9dbab6f.htm"),\ WS_SYSMENU,0,0,300,300,NULL,NULL,hInstance,NULL
And now i can close it !
It was like a game.Under is what you said.
Quote
It's very easy to use and can be used as a container for just about any class of COM object, hard to beat for simplicity.
I have made it,I win :lol
More seriously,i have already write some implementation of com interface and there is a lot of answers to give.
I you have a look on the atl interfaces,you see TranslateUrl in the IDocHostUIHandlerDispatch interface. I supposed that the dll can do manything with the browser .
It also provide a Iunknown interface with the window.I have see a sample somewhere.
Here's an example program using the ATL and an event sync to put the name of the page in the title bar when the page has finished loading.
[attachment deleted by admin]
Just a question,where did you find the values of the browser events ?
Quote from: ToutEnMasm on February 18, 2009, 08:29:34 AM
Just a question,where did you find the values of the browser events ?
They are in ExDispid.h in my headers or any VS release except Express.
Thanks,don't found it in the SDK (6.1) ,neither in the ddk
Quote from: ToutEnMasm on February 18, 2009, 05:11:22 PM
Thanks,don't found it in the SDK (6.1) ,neither in the ddk
No problem, the MFC headers are not distributed with the DDK, SDK, MSDN library or Visual Studio Express, only with a VS Standard or VS pro release (AFAIK). However, the headers are available in my latest header package uploaded last night.
may someone attach me atl.lib or give me a link to download atl.lib ? I try to search with google. but I get nothing.
I have download atl.dll from : http://www.softpicks.net/dll/atl-dll-12754.html
thank you.
sorry for my bad english
Hi elmo,
GoAsm does not use import libraries so there isn't a lot of chance to get it in this forum. Also since the ATL is COM I'm not completely sure there is a MASM import library for it since it is a registered COM server. ATL.DLL should be preinstalled with Windows or at least IE so there is no need to download it, it might actually do some damage to your system if you overwrite the existing version with a downloaded one. Someone might have an INC file for it or you can translate the appropriate headers from GoAsm to MASM syntax.
Edgar
btw, any chance to enumerate links like:
Dim Link
For Each Link In objie.Document.Links
ss=link.href
st=link.innerHTML
next