Page 1 of 1

Thread & Webgadget & Com question

Posted: Sat Aug 23, 2008 8:37 am
by Rascal
Code in the second cycle after the error has occurred.

I now propose to the problem, and before the issue is absolutely not the same,

No previous use of threads.

Now the use of the thread.

trouble you to help solve the problem.

This problem has been bothering the good days.

Code: Select all


Enumeration 
  #Web_0 
  #Panel_0 
  #Window_0 
EndEnumeration 

Declare   Main() 
Declare   WebBrowser_(INT.l) 
Declare.l WebBrowser_Refresh(Gadget.l) 

;- 
Procedure WebBrowser_(INT.l) 
Url.s = PeekS(INT) 
If OpenWindow(#Window_0,#Null,#Null,1000,700,#NULL$,#PB_Window_SystemMenu) 
 If CreateGadgetList(WindowID(#Window_0)) 
     PanelGadget(#Panel_0,#Null,#Null,1000,700) 
     AddGadgetItem(#Panel_0,1,"Ok") 
     WebGadget(#Web_0,#Null,#Null,WindowWidth(#Window_0)-3,WindowHeight(#Window_0)-22,Url) 
     CloseGadgetList() 
 EndIf 
 Repeat 
 Until WaitWindowEvent() = #PB_Event_CloseWindow 
EndIf 
EndProcedure 

;- 
Procedure.l WebBrowser_Refresh(Gadget.l) 
CoInitialize_(#Null)
Res.l                         = #False
IWebBrowser2.IWebBrowser2     = GetWindowLong_(GadgetID(Gadget),#GWL_USERDATA) 
IDispatch.IDispatch           = #Null
IHTMLDocument2.IHTMLDocument2 = #Null
If IWebBrowser2
 If IWebBrowser2\get_Document(@IDispatch) = #S_OK And IDispatch
  If IDispatch\QueryInterface(?IID_IHTMLDocument2,@IHTMLDocument2) = #S_OK And IHTMLDocument2
   If IHTMLDocument2\execCommand("Refresh",#VARIANT_TRUE,@VAR.VARIANT,@pfRet) = #S_OK
      Res = #True
   EndIf
   IHTMLDocument2\Release()
  EndIf
  IDispatch\Release()
 EndIf
EndIf
CoUninitialize_()
ProcedureReturn Res 
EndProcedure 

DataSection 
  IID_IHTMLDocument2:
    Data.l $332C4425 
    Data.w $26CB, $11D0 
    Data.b $B4, $83, $00, $C0, $4F, $D9, $01, $19
EndDataSection

;- 
Procedure Main() 
While #True 
Url.s = "about:blank" 
Thread.l = CreateThread(@WebBrowser_(),@Url) 
Sleep_(1000*5) 

Debug WebBrowser_Refresh(#Web_0) 
Sleep_(1000*5) 

KillThread(Thread) 
Wend 
EndProcedure 

WaitThread(CreateThread(@Main(),#Null))

[02:17:29] Waiting for executable to start...
[02:17:29] Executable started.
[02:17:44] [ERROR] WebBrowser.pb (Line: 36)
[02:17:44] [ERROR] Invalid memory access. (write error at address 56)
[02:17:47] The Program was killed.

Posted: Sat Aug 23, 2008 2:15 pm
by Sparkie
Rascal, tell us what you are trying to accomplish with your program and maybe helping you will be easier....then you can stop creating new threads for the same problem.

Also, read the PB help file and look under WebGadget. It will be very refreshing.

Posted: Sat Aug 23, 2008 2:45 pm
by freak
Stop creating new topics about the same thing. It is annoying.
If people didn't help you in the previous topics, they won't help you here either.

As for your problems:
Just don't use threads with the WebGadget. COM+Threads is just not a good combination.

Posted: Sat Aug 23, 2008 2:56 pm
by Little John
... and try to write complete and understandable sentences.
Otherwise it's simply (almost) impossible to help you!

Annoyed, Little John

Posted: Wed Aug 27, 2008 3:21 pm
by Rascal
Nobody knows to solve problem ???

Posted: Wed Aug 27, 2008 3:31 pm
by freak
I told you: WebGadget+Threads=trouble. Just don't do it.

Posted: Wed Aug 27, 2008 4:34 pm
by Rascal
I must do this procedure ah.
Or trouble you to help me solve

Posted: Wed Aug 27, 2008 4:37 pm
by Sparkie
Maybe if you would tell us what it is you are trying to accomplish here, we could offer some help. Your communication skills need some work. ;)