Avec le code ci joint livré avec COMate j'y arrive mais uniquement pour un WebGadget. J'ai parcouru tous les forums français et étranger mais je n'ai malheureusement pas trouvé.
Le but étant de récuperer quelques infos sur la page pour créer une liste, ce qui me fera gagner un temps considérable (pour mon boulot)
Toute aide est la bienvenue. Merci
Code : Tout sélectionner
;***COMate*** COM automation through iDispatch.
;*===========
;*
;*Web gadget demo. (Advanced users!) Based upon code by hm.
;*
;*This demo not only shows how to obtain a COMateObject from a web-gadget, but also sets a 'global' event handler.
;*
;*This demo also shows how to over-ride the COMateObject SetEventHandler() method and direct COMate to seek out a specific
;*'out-going interface'. Left to it's own devices, COMatePLUS will utilise the first suitable 'connection point' and out-going interface
;*that it encounters. In the case of a web gadget, we direct COMatePLUS to directly seek out a connection point for the newer DWebBrowserEvents2
;*interface.
;*I did state that this demo is for advanced users!
;/////////////////////////////////////////////////////////////////////////////////
IncludePath "..\"
XIncludeFile "COMatePLUS.pbi"
Define.COMateObject browser, document
Enumeration
#Web_Gadget
#Button_Start
EndEnumeration
;/////////////////////////////////////////////////////////////////////////////////
;The following is our event callback for our web-gadget object.
;The 'Object' parameter will contain the COMate object upon which was used the \SetEventHandler() method; in our case it will point
;to our browser object.
Procedure EventProc(Object.COMateObject, eventName$, parameterCount)
Debug eventName$
EndProcedure
;/////////////////////////////////////////////////////////////////////////////////
If OpenWindow(0, 302, 15, 600, 300, "WebGadget Events Test", #PB_Window_SystemMenu | #PB_Window_TitleBar )
WebGadget(#Web_Gadget, 20, 20, 560, 215, "http://wwww.purebasic.com")
; ButtonGadget(#Button_Start, 20, 250, 110, 40, "Start")
; ButtonGadget(100, 120, 250, 110, 40, "Edit")
; ButtonGadget(200, 220, 250, 110, 40, "Bold")
ButtonGadget(300, 320, 250, 110, 40, "GetHTML")
;hwnd = FindWindow_("IEFrame",0)
;browser = COMate_WrapCOMObject(GetWindowLongPtr_(hwnd, #GWL_USERDATA))
browser = COMate_WrapCOMObject(GetWindowLongPtr_(GadgetID(#Web_Gadget), #GWL_USERDATA))
document = browser\GetObjectProperty("Document")
;Set the 'global' event handler for the browser object.
;In order to over-ride COMatePLUS' selection of 'connection point' we pass a pointer to the IID of the DWebBrowserEvents2 out-going interface
;within the second optional parameter.
If COMate_GetIIDFromName("DWebBrowserEvents2", @iid.IID) = #S_OK
; browser\SetEventHandler(#COMate_CatchAllEvents, @EventProc(), 0, iid)
EndIf
EndIf
Repeat
EventID = WaitWindowEvent()
Select EventID
Case #PB_Event_Gadget
Select EventGadget()
Case 300
; a$ = GetGadgetItemText(#Web_Gadget, #PB_Web_HtmlCode,#PB_Web_HtmlCode)
a$ = document\GetStringProperty("body\InnerHTML")
MessageRequester("", a$)
; Case 200
; document\Invoke("execCommand('bold', #False, #Void)")
; Case 100
; document\SetProperty("DesignMode = 'on'")
; Debug Comate_GetLastErrorDescription()
; Case #Button_Start
; browser\Invoke("Navigate('http://www.purebasic.com/')")
EndSelect
EndSelect
Until EventID = #PB_Event_CloseWindow
browser\Release()
End