Page 3 of 4

Posted: Tue Jun 01, 2004 4:16 pm
by dmoc
Search the forums. I've posted code previously to get the IID

Found it... viewtopic.php?t=7777

...is this what you wanted?

Posted: Tue Jun 01, 2004 5:09 pm
by ricardo
Edwin Knoppert wrote:I think you'll need to query using the IID for these interfaces.
I don't think it's useful though.
Can you explain a little more please? :D

Thanks

Posted: Tue Jun 01, 2004 6:48 pm
by Edwin Knoppert
QueryInterface (member of iunknown) should be used to obtain interfaces.
A valid (supported IID) is required.

I say i'm only guessing you might get access to these interfaces, i'm not sure..

Posted: Tue Jun 01, 2004 10:51 pm
by aXend
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.

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

Posted: Wed Jun 02, 2004 7:31 pm
by aXend
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

Posted: Thu Jul 08, 2004 10:02 am
by bingo
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)
:?:

Re: Interface Generator 1.0 - Get it!

Posted: Thu Jul 08, 2004 10:36 am
by PB
> 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...? :(

Re: Interface Generator 1.0 - Get it!

Posted: Thu Jul 08, 2004 3:49 pm
by NoahPhense
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...? :(
Yeah I still don't understand PB Interfaces yet, but that's my own fault.
So, what is this generator, and how do we use it?

- np

Re: Interface Generator 1.0 - Get it!

Posted: Mon Jul 12, 2004 11:52 pm
by PB
> what is this generator, and how do we use it?

Anybody care to explain it to us, please? 8O

Posted: Tue Jul 13, 2004 10:02 am
by Fred
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).

Posted: Tue Jul 13, 2004 10:31 am
by thefool
that light's things up a bit. Thanks!

Posted: Tue Jul 13, 2004 11:08 am
by LarsG
hmm.. it just seems like more of a mess to me..
I really don't get it.. :(

Posted: Tue Jul 13, 2004 11:12 am
by thefool
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.

Posted: Tue Jul 13, 2004 2:07 pm
by Fred
If we take the previous example with the Timer, a sample code could look like this:

Old way:

Code: Select all

  MyTimer = CreateTimer()
  SetTimerBase(MyTimer, 10)
  ResetTimer(MyTimer)
New Way (using intefaces):

Code: Select all

  CreateTimer(@MyTimer.TimerInterface)
  MyTimer\SetBase(10)
  MyTimer\ResetTimer()
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.

..

Posted: Tue Jul 13, 2004 7:18 pm
by NoahPhense
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