Interface Generator 1.0 - Get it!
-
- Addict
- Posts: 1073
- Joined: Fri Apr 25, 2003 11:13 pm
- Location: Netherlands
- Contact:
You have to use Shell.Explorer in addition to Shell.Application. If you enter this in Interface Generator you get amongst others the IWebBrowser Interface. This shows the get_Document method. This method gives an object that points to the DOM. BTW this IWebBrowser interface is already defined in PB (see Tools\Structures\Interfaces).
The problem is that it crashes in PB. I haven't figured out why yet. May be you can find it? This is the code that stops when calling the Item method.
The problem is that it crashes in PB. I haven't figured out why yet. May be you can find it? This is the code that stops when calling the Item method.
Code: Select all
Interface myIShellWindows Extends IDispatch
get_Count(a)
Item(a,b,c,d,e)
_NewEnum(a)
Register(a,b,c,d)
RegisterPending(a,b,c,d,e)
Revoke(a)
OnNavigate(a,b)
OnActivated(a,b)
FindWindowSW(a,b,c,d,e,f)
OnCreated(a,b)
ProcessAttachDetach(a)
EndInterface
Global None.VARIANT
None\vt = #VT_ERROR
None\scode = #DISP_E_PARAMNOTFOUND
OnErrorGoto(?Finish)
oShell.IShellDispatch = CreateObject("Shell.Application")
;Debug oShell
oShell\Windows(@oShellWindows.myIShellWindows)
Debug oShellWindows
If oShellWindows
item.VARIANT\vt = #VT_UI4
item\iVal = 0
*item.pToVariant = item
CallDebugger
err.l = oShellWindows\Item(*item\a,*item\b,*item\c,*item\d,@objIE.IWebBrowser2)
If = #S_OK
Debug "OK"
Else
Debug err
EndIf
EndIf
Finish:
If oShellWindows
ReleaseObject(oShellWindows)
EndIf
If oShell
ReleaseObject(oShell)
EndIf
End
I found the solution. It needs some extra steps to get to the right object.
Code: Select all
Interface myIShellWindows Extends IDispatch
get_Count(a)
Item(a,b,c,d,e)
_NewEnum(a)
Register(a,b,c,d)
RegisterPending(a,b,c,d,e)
Revoke(a)
OnNavigate(a,b)
OnActivated(a,b)
FindWindowSW(a,b,c,d,e,f)
OnCreated(a,b)
ProcessAttachDetach(a)
EndInterface
Enumeration
#Popup
#Text
#Button
EndEnumeration
#CRLF = Chr(13) + Chr(10)
Global None.VARIANT
None\vt = #VT_ERROR
None\scode = #DISP_E_PARAMNOTFOUND
*None.pToVariant = None
OnErrorGoto(?Finish)
Procedure WinPopup()
If OpenWindow(#Popup,0,0,400,200,#PB_Window_ScreenCentered,"HTML Document Browser")
If CreateGadgetList(WindowID(#Popup))
TextGadget(#Text,0,0,WindowWidth(),WindowHeight()-30,"",#PB_Text_Center | #PB_Text_Border)
ButtonGadget(#Button,(WindowWidth()-30)/2,175,30,20,"OK",#PB_Button_Default)
HideWindow(#Popup,1)
ProcedureReturn #True
EndIf
EndIf
EndProcedure
Procedure Popup()
quitwindow = #False
HideWindow(#Popup,0)
Repeat
Event = WaitWindowEvent()
If Event = #PB_EventGadget
;Debug "WindowID: " + Str(EventWindowID())
GadgetID = EventGadgetID()
If GadgetID = #Button
; Debug "GadgetID: #Button"
quitwindow = #True
EndIf
EndIf
Until quitwindow
HideWindow(#Popup,1)
EndProcedure
Procedure ExploreHTML(pHTML.l)
*HTML.IHTMLDocument2 = pHTML
outtxt.s=""
*HTML\get_URL(@URL.l)
*HTML\get_title(@title.l)
outtxt = Uni2Ansi(URL) + #CRLF
outtxt = outtxt + Uni2Ansi(title) + #CRLF
SetGadgetText(#Text,outtxt)
Popup()
EndProcedure
If WinPopup()
oShell.IShellDispatch = CreateObject("Shell.Application")
oShell\Windows(@oShellDisp.IDispatch)
oShellDisp\QueryInterface(?IID_IShellWindows,@oShellWindows.myIShellWindows)
If oShellWindows
oShellWindows\Item(*None\a,*None\b,*None\c,*None\d,@oFolder.IDispatch)
If oFolder<> 0
oFolder\QueryInterface(?IID_IWebBrowser2,@objIE.IWebBrowser2)
If objIE <> 0
objIE\get_Document(@oDocument.IDispatch)
If oDocument
oDocument\QueryInterface(?IID_IHTMLDocument2,@oHTML.IHTMLDocument2)
If oHTML
ExploreHTML(oHTML)
Else
MessageRequester("Document","Can't create HTML Interface",0)
EndIf
Else
MessageRequester("WebBrowser","Can't create Document",0)
EndIf
Else
MessageRequester("Folder","Can't create WebBrowser Interface",0)
EndIf
Else
MessageRequester("ShellWindows","There is no open browser window",0)
EndIf
Else
MessageRequester("Shell","Can't create ShellWindows Interface",0)
EndIf
EndIf
Finish:
CloseWindow(#Popup)
If oHTML
ReleaseObject(oHTML)
EndIf
If oDocument
ReleaseObject(oDocument)
EndIf
If objIE
ReleaseObject(objIE)
EndIf
If oFolder
ReleaseObject(oFolder)
EndIf
If oShellWindows
ReleaseObject(oShellWindows)
EndIf
If oShellDisp
ReleaseObject(oShellDisp)
EndIf
If oShell
ReleaseObject(oShell)
EndIf
End
DataSection
IID_IShellWindows:
Data.l $85CB6900
Data.w $4D95,$11CF
Data.b $96,$0C,$00,$80,$C7,$F4,$EE,$85
EndDataSection
DataSection
IID_IWebBrowser2:
Data.l $D30C1661
Data.w $CDAF,$11D0
Data.b $8A,$3E,$00,$C0,$4F,$C9,$E2,$6E
EndDataSection
DataSection
IID_IHTMLDocument2:
Data.l $332C4425
Data.w $26CB,$11D0
Data.b $B4,$83,$00,$C0,$4F,$D9,$01,$19
EndDataSection
wsh-variable -> pb-variable
how convert 'value' in pb-variable ???

Code: Select all
IncludeFile "msscript interface.pb" ;the one showed here before
object.IScriptControl = CreateObject("MSScriptControl.ScriptControl.1")
object\_AboutBox()
object\put_Language(Ansi2Uni("vbscript"))
object\ExecuteStatement(Ansi2Uni("Value = (3*3)+100"))
;how convert 'value' in pb-variable ???
ReleaseObject(object)

["1:0>1"]
Re: Interface Generator 1.0 - Get it!
> The Interface Generator is finished
I'm probably the only one to ask this: but what is it for? I ran it and don't
understand what it's supposed to do...?
I'm probably the only one to ask this: but what is it for? I ran it and don't
understand what it's supposed to do...?

- NoahPhense
- Addict
- Posts: 1999
- Joined: Thu Oct 16, 2003 8:30 pm
- Location: North Florida
Re: Interface Generator 1.0 - Get it!
Yeah I still don't understand PB Interfaces yet, but that's my own fault.PB wrote:> The Interface Generator is finished
I'm probably the only one to ask this: but what is it for? I ran it and don't
understand what it's supposed to do...?
So, what is this generator, and how do we use it?
- np
Re: Interface Generator 1.0 - Get it!
> what is this generator, and how do we use it?
Anybody care to explain it to us, please? 8O
Anybody care to explain it to us, please? 8O
Since a while, Microsoft introduced a so called 'COM' technology (Common Object Model) which are basically the future of the win32 API. These objects are more and more spreaded in the API (see DirectX for example) as it's much easier to manage and gives more flexibility. Let's compare the 'old' way and the 'new' way:
Old:
The Timer.dll will have the following functions:
Handle = CreateTimer()
SetTimerBase(Handle, Base)
ResetTimer(Handle)
It's the 'old' way, so you can call this directly as you do for many other WinAPI functions.
Now, the 'new' way (which use interfaces, as we speaking of this):
The Timer.dll will have only one function:
CreateTimer(@Timer.TimerInterface)
And the TimerInterface would look like this:
Interface TimerInterface
SetBase(Base)
Reset()
EndInterface
So, as you can see, you need an Interface definition to access this component which isn't defined anywhere. The above tool creates the interface from the 'definition files' which are supplied with any com component (or should be).
Old:
The Timer.dll will have the following functions:
Handle = CreateTimer()
SetTimerBase(Handle, Base)
ResetTimer(Handle)
It's the 'old' way, so you can call this directly as you do for many other WinAPI functions.
Now, the 'new' way (which use interfaces, as we speaking of this):
The Timer.dll will have only one function:
CreateTimer(@Timer.TimerInterface)
And the TimerInterface would look like this:
Interface TimerInterface
SetBase(Base)
Reset()
EndInterface
So, as you can see, you need an Interface definition to access this component which isn't defined anywhere. The above tool creates the interface from the 'definition files' which are supplied with any com component (or should be).
hmm.. it just seems like more of a mess to me..
I really don't get it..
I really don't get it..

AMD Athlon XP2400, 512 MB RAM, Hercules 3D Prophet 9600 256MB RAM, WinXP
PIII 800MHz, 320 MB RAM, Nvidia Riva Tnt 2 Mach 64 (32MB), WinXP + Linux
17" iMac, 1.8 GHz G5, 512 MB DDR-RAM, 80 GB HD, 64 MB Geforce FX 5200, SuperDrive, OSX
it dosent clears it all up for me, thats why i said "a bit".
I understand a little bit about it using interfaces and stuff, but i think some good examples would be great. So many people says "Great. Really usefull", and i (and all the other not understanding it) would really like to see what this is all about, and how to use it.
I understand a little bit about it using interfaces and stuff, but i think some good examples would be great. So many people says "Great. Really usefull", and i (and all the other not understanding it) would really like to see what this is all about, and how to use it.
If we take the previous example with the Timer, a sample code could look like this:
Old way:
New Way (using intefaces):
It's just 2 differents approaches to do the same things. You could think: "ok, so I choose the old way, the one I am familiar with", but unfortunately many componenent have now only one way to access them, the COM one.
It's almost the same difference between a procedural based language like PureBasic and an object oriented langage like Java.
Old way:
Code: Select all
MyTimer = CreateTimer()
SetTimerBase(MyTimer, 10)
ResetTimer(MyTimer)
Code: Select all
CreateTimer(@MyTimer.TimerInterface)
MyTimer\SetBase(10)
MyTimer\ResetTimer()
It's almost the same difference between a procedural based language like PureBasic and an object oriented langage like Java.
- NoahPhense
- Addict
- Posts: 1999
- Joined: Thu Oct 16, 2003 8:30 pm
- Location: North Florida
..
I've backed up a little bit.. I've been looking over the code in the
codearchiv :: \CodeArchiv 1.8\Other\OOP\ ..
Some ok examples in there.. using Interfaces.
- np
codearchiv :: \CodeArchiv 1.8\Other\OOP\ ..
Some ok examples in there.. using Interfaces.
- np