WebGadget DocumentComplete event
WebGadget DocumentComplete event
In Visual Basic the 'WebControl' fires a DocumentComplete event when a document has finished loading (see http://msdn.microsoft.com/workshop/brow ... frame=true)
Doesn't the WebGadget in PureBasic (or the IWebBrowser2 object 'inside' it) do something like this?
How do I make a handler for it?
Doesn't the WebGadget in PureBasic (or the IWebBrowser2 object 'inside' it) do something like this?
How do I make a handler for it?
- NoahPhense
- Addict
- Posts: 1999
- Joined: Thu Oct 16, 2003 8:30 pm
- Location: North Florida
Re: WebGadget DocumentComplete event
Code: Select all
#READYSTATE_UNINITIALIZED = 0
; The control is waiting to be initialized
#READYSTATE_LOADING = 1
; The control is initializing itself through
; one Or more asynchronous properties. Some
; property values might not be available.
#READYSTATE_LOADED = 2
; The control has returned from IPersist*::Load
; so that all its properties are available And
; it has started any asynchronous Data transfers.
; The control's properties are available and it is
; ready To draw at least something through IViewObject::draw.
; Making properties available doesn't necessarily require
; The control's type information.
#READYSTATE_INTERACTIVE = 3
; The control is capable of interacting with the user in at
; least some limited sense And can supply its type information.
; Full interaction may not be available Until all asynchronous
; Data arrives
#READYSTATE_COMPLETE = 4
; The control is completely ready for all requests.
If OpenWindow(0, 10, 10, 700, 500, #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget, "WebGadget ReadyState")
If CreateStatusBar(0, WindowID())
StatusBarText(0, 0, "")
EndIf
If CreateGadgetList(WindowID())
WebGadget(0, 10, 10, 680, 460, "http://www.purebasic.com")
WebObject.IWebBrowser2 = GetWindowLong_(GadgetID(0), #GWL_USERDATA) ; needed for accessing IWebBrowser interface
EndIf
EndIf
Repeat
Event = WaitWindowEvent()
If isBusy
WebObject\get_ReadyState(@isReady)
Select isReady
Case 1
StatusBarText(0, 0, "Page Loading")
Case 2
StatusBarText(0, 0, "Page Loaded")
Case 3
StatusBarText(0, 0, "Page is interactive with some data missing")
Case 4
StatusBarText(0, 0, "Page finished loading")
EndSelect
EndIf
WebObject\get_busy(@isBusy)
Until Event = #PB_Event_CloseWindow
End
Last edited by NoahPhense on Sun Jul 18, 2004 9:55 pm, edited 1 time in total.
thanks, and sorry that I did not make my intention with the posting completely clear. My problem actually is not to find out when a document has finished loading - that was just an example. My problem is, quite generally, that I would like to be able to set up handlers for events that I think (?) the WebGadget should be firing.
If I just knew to which window these events are sent, I guess I could handle the events in a window callback for that window..
If I just knew to which window these events are sent, I guess I could handle the events in a window callback for that window..
- NoahPhense
- Addict
- Posts: 1999
- Joined: Thu Oct 16, 2003 8:30 pm
- Location: North Florida
..
What type of events are you trying to catch?
- np
- np
- NoahPhense
- Addict
- Posts: 1999
- Joined: Thu Oct 16, 2003 8:30 pm
- Location: North Florida
..
The WebBrowser Control fires the DocumentComplete event when the
document has completely loaded and the READYSTATE property has
changed to READYSTATE_COMPLETE.
Let's see if Freak can help..
- np
document has completely loaded and the READYSTATE property has
changed to READYSTATE_COMPLETE.
Let's see if Freak can help..
- np
I've spent the entire weekend Googling my little a$$ off in hopes of figuring out all this IWebBrowser... IHTMLDocument2... IHTMLAnchorElement... IUnknown... DWebBrowserEvents2... IConnectionPointContainer... HTMLElementEvents2... blah...blah...blah
I have made some headway, but trying to convert c... c++... ATL... VB... VC... XYZ... DoBeDoBeDo code to PB has me going insane. 8O
I'm making some progress but don't hold your breath waiting for any results.

I have made some headway, but trying to convert c... c++... ATL... VB... VC... XYZ... DoBeDoBeDo code to PB has me going insane. 8O
I'm making some progress but don't hold your breath waiting for any results.

What goes around comes around.
PB 5.21 LTS (x86) - Windows 8.1
PB 5.21 LTS (x86) - Windows 8.1
- NoahPhense
- Addict
- Posts: 1999
- Joined: Thu Oct 16, 2003 8:30 pm
- Location: North Florida
..
Maybe you could point us to the IWebBrowser2 structure/interface.. thatfreak wrote:Sorry, i have no idea how to connect to such events.![]()
Timo
is built into pb? I know where the one is at MSDN.. but it seems that
the PB syntax differs a bit.
- np
Solution seems to be DWebBrowserEvents2 Interface :
Link to MSDN:http://msdn.microsoft.com/library/defau ... vents2.asp

Link to MSDN:http://msdn.microsoft.com/library/defau ... vents2.asp

DWebBrowserEvents2 is just the tip of the iceberg Nico. 
I'm inching along ever so s...l...o...w...l...y. At this point, I think I have converted 75% of what we need.
I can see events (I think) as they happen but I don't know which events they are 8O
Here's what I'm trying to understand/convert. That is one of several I'm working with but it has moved me along the furthest.

I'm inching along ever so s...l...o...w...l...y. At this point, I think I have converted 75% of what we need.

Here's what I'm trying to understand/convert. That is one of several I'm working with but it has moved me along the furthest.
What goes around comes around.
PB 5.21 LTS (x86) - Windows 8.1
PB 5.21 LTS (x86) - Windows 8.1
- NoahPhense
- Addict
- Posts: 1999
- Joined: Thu Oct 16, 2003 8:30 pm
- Location: North Florida
..
ok.. try this out..
use the interface generator on your SHDOCVW.DLL
the one in your system32 dir..
im still tooling with it.. we'll see
- np
use the interface generator on your SHDOCVW.DLL
the one in your system32 dir..
im still tooling with it.. we'll see
- np
Thanks np, I looked at it but I'm not sure what the InterfaceGenerator will do in this situation that Fred & Co. haven't already done 
From what I've seen so far via the PB Interface viewer, all needed interfaces for this are already defined in PB. Am I missing something here


From what I've seen so far via the PB Interface viewer, all needed interfaces for this are already defined in PB. Am I missing something here


What goes around comes around.
PB 5.21 LTS (x86) - Windows 8.1
PB 5.21 LTS (x86) - Windows 8.1
- NoahPhense
- Addict
- Posts: 1999
- Joined: Thu Oct 16, 2003 8:30 pm
- Location: North Florida
..
Ok, I've got the solution. There's only one catch,
it's in C++ and *I'm* not converting it..
I have the entire project source, the dsp, dsw, etc..
We really only need like 2 maybe 3 procedures out of it..
If someone wants to give it a whirl, I'll post the project.
- np
it's in C++ and *I'm* not converting it..
I have the entire project source, the dsp, dsw, etc..
We really only need like 2 maybe 3 procedures out of it..
Code: Select all
// Document loaded and initialized
void SimpleBrowser::_OnDocumentComplete(LPDISPATCH lpDisp,VARIANT *URL)
{
if (lpDisp == _BrowserDispatch) {
CString URL_string;
if ((URL != NULL) &&
(V_VT(URL) == VT_BSTR)) {
URL_string = V_BSTR(URL);
}
OnDocumentComplete(URL_string);
}
}
void SimpleBrowser::OnDocumentComplete(CString URL)
{
CWnd *parent = GetParent();
if (parent != NULL) {
Notification notification(m_hWnd,GetDlgCtrlID(),DocumentComplete);
notification.URL = URL;
LRESULT result = parent->SendMessage(WM_NOTIFY,
notification.hdr.idFrom,
(LPARAM)¬ification);
}
}
- np
Thanks np.
I can add that to the cpp code I dl'd from Incorporating the WebBrowser Control into Your Program. The sample code is located at the top of that page in a self-extracting zip.
The page actually does a pretty good job of explaining the interfaces needed for certain tasks, so once we break through the cpp barrier we could be a few steps closer to success.
After looking at the cpp code, I have a much greater appreciation for Fred & Co. and the ease of coding in PB!

The page actually does a pretty good job of explaining the interfaces needed for certain tasks, so once we break through the cpp barrier we could be a few steps closer to success.

After looking at the cpp code, I have a much greater appreciation for Fred & Co. and the ease of coding in PB!

What goes around comes around.
PB 5.21 LTS (x86) - Windows 8.1
PB 5.21 LTS (x86) - Windows 8.1