COMatePLUS version 1.2

Developed or developing a new product in PureBasic? Tell the world about it.
KIKI
Enthusiast
Enthusiast
Posts: 145
Joined: Thu Dec 28, 2006 11:49 am
Location: FRANCE

Re: COMatePLUS version 1.1

Post by KIKI »

srod wrote:Which code snippet generates the error Anthony?
See my post higher i have the same problem with PB 4.41 executing any kind of programm
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Re: COMatePLUS version 1.1

Post by srod »

I have posted a bug report about this.

http://www.purebasic.fr/english/viewtop ... =4&t=40750
I may look like a mule, but I'm not a complete ass.
KIKI
Enthusiast
Enthusiast
Posts: 145
Joined: Thu Dec 28, 2006 11:49 am
Location: FRANCE

Re: COMatePLUS version 1.1

Post by KIKI »

I am sorry SROD but the problem is not solved even if you start with a clean version of PB4.41. I have always the problem. It seems that your bug probelm was'nt record by fred
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Re: COMatePLUS version 1.1

Post by srod »

Kiki, this is a Purebasic bug which I have reported. Worry not, Fred will fix it.

Whilst I could easily work around this, I think it is better to wait for the bug to be fixed in Purebasic.

http://www.purebasic.fr/english/viewtop ... =4&t=40750
I may look like a mule, but I'm not a complete ass.
SFSxOI
Addict
Addict
Posts: 2970
Joined: Sat Dec 31, 2005 5:24 pm
Location: Where ya would never look.....

Re: COMatePLUS version 1.1

Post by SFSxOI »

srod, is it possible that you could pass along the work around while waiting on the bug fix in PB?
The advantage of a 64 bit operating system over a 32 bit operating system comes down to only being twice the headache.
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Re: COMatePLUS version 1.1

Post by srod »

No, but you can do it yourself if you are in need.

Switch all instances of '+', '-' for their Ascii codes etc. That should fix it.
I may look like a mule, but I'm not a complete ass.
SFSxOI
Addict
Addict
Posts: 2970
Joined: Sat Dec 31, 2005 5:24 pm
Location: Where ya would never look.....

Re: COMatePLUS version 1.1

Post by SFSxOI »

well, thats what I meant. :)

Thanks srod :)
The advantage of a 64 bit operating system over a 32 bit operating system comes down to only being twice the headache.
User avatar
chi
Addict
Addict
Posts: 1087
Joined: Sat May 05, 2007 5:31 pm
Location: Austria

Re: COMatePLUS version 1.1

Post by chi »

Why is ExecuteJavaScript to a threaded window not working? Did I miss something :wink:

Code: Select all


IncludePath "..\"
XIncludeFile "COMatePLUS.pbi"

Enumeration
  #Win1  
  #Web1
  #B1
EndEnumeration

#URL = "javascript:document.write("+Chr(34) +"<script type='text/javascript'> function Test(v) { alert(v); return v; } </script><body><input type='button' value=' test ' onclick='window.Test(3);'></body>" +Chr(34)+");document.close()"

Define.COMateObject WebObject

Procedure.i ExecuteJavaScript(Gadget, command$) 
  Protected browser.COMateObject, documentDispatch.COMateObject, script.COMateObject
  Protected result
  browser = COMate_WrapCOMObject(GetWindowLong_(GadgetID(gadget), #GWL_USERDATA)) 
  If browser 
    documentDispatch = browser\GetObjectProperty("Document")
    If documentDispatch
      script = documentDispatch\GetObjectProperty("script")
      If script
        result = script\Invoke("eval('" + command$ + "')")
        script\release()
      EndIf  
      documentDispatch\Release()
    EndIf
    browser\Release()
  EndIf 
  ProcedureReturn result
EndProcedure

Procedure OpenWin1(param)
  
  If OpenWindow(#Win1, #PB_Ignore, #PB_Ignore, 440, 280, "win1", #PB_Window_SystemMenu|#PB_Window_MinimizeGadget|#PB_Window_TitleBar|#PB_Window_ScreenCentered)
    WebGadget(#Web1, 0, 0, 440, 250, #URL)
    While WindowEvent():Wend
    ButtonGadget(#B1, 5, 255, 95, 20, "test")
  EndIf
  
  Repeat
    event=WaitWindowEvent()
    Select event        
      Case #PB_Event_Gadget        
        Select EventGadget()
            
          Case #B1
            ExecuteJavaScript(#Web1,"window.Test(1);")
            
        EndSelect        
    EndSelect
  Until event=#PB_Event_CloseWindow
  
EndProcedure

thread=CreateThread(@OpenWin1(),0)
WaitThread(thread,3000)

Debug ExecuteJavaScript(#Web1,"window.Test(1);")

Repeat
  WaitWindowEvent(16)
  x+1
Until x=180

End
thx, chi
Et cetera is my worst enemy
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Re: COMatePLUS version 1.1

Post by srod »

The problem is that the COM object is being created in your thread and you are attempting to access it in your main process with the line :

Code: Select all

Debug ExecuteJavaScript(#Web1,"window.Test(1);")
This breaks the single threaded apartment model which Purebasic initialises. In this model you cannot pass COM objects between threads etc. This has been discussed before and Freak pointed out that Purebasic cannot use a multi-threaded apartment model because, amongst other things, OLE is not strictly threadsafe and OLE is required for things like drag-and-drop etc.

Comment the offending line out and everything works fine.

There are ways around this, in that there are COM functions designed to allow us to circumvent this limitation and to marshall an object created in one thread for use in another thread etc. This is not something I wish to implement, however, because it will only complicate matters and so few people would ever need this.

The point is that you will need to keep each object you create for exclusive use within the thread which created the object etc. I'm sure you'll find a way! :)
I may look like a mule, but I'm not a complete ass.
User avatar
chi
Addict
Addict
Posts: 1087
Joined: Sat May 05, 2007 5:31 pm
Location: Austria

Re: COMatePLUS version 1.1

Post by chi »

Thank you for pointing this out, srod!
Guess i´ll have to stick with the idea to use get/setwindowtitle... a little bit odd but good enough for now ;)
Or any better ideas? Anyway, thx again...

chi


edit: btw. it´s for a .dll
Et cetera is my worst enemy
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Re: COMatePLUS version 1.1

Post by srod »

Simplest way is to send a message to the thread (via a global variable or registering your own window message etc.) instructing the thread to perform some task or other with the COM object. This way, when the main process requires access to the COM object, rather than do it directly (and cause an access error) get the thread to do it.
I may look like a mule, but I'm not a complete ass.
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Re: COMatePLUS version 1.2

Post by srod »

Update - 9th July 2010.

Version 1.2 (Purebasic 4.5 edition).

A bug in COMatePLUS' error reporting has been fixed in the Purebasic 4.5 edition of COMatePLUS. Other editions were not affected by this bug because I inadvertently created COMatePLUS for PB 4.5 from an out of date version of COMatePLUS... doh!!! How the hell I did that is beyond me? :)

See the nxSoftware site for the download.
I may look like a mule, but I'm not a complete ass.
User avatar
Kiffi
Addict
Addict
Posts: 1485
Joined: Tue Mar 02, 2004 1:20 pm
Location: Amphibios 9

Re: COMatePLUS version 1.2

Post by Kiffi »

srod wrote:A bug in COMatePLUS' error reporting has been fixed in the Purebasic 4.5 edition of COMatePLUS.
thanks a lot! Image

Greetings ... Kiffi
Hygge
User avatar
GeBonet
Enthusiast
Enthusiast
Posts: 135
Joined: Fri Apr 04, 2008 6:20 pm
Location: Belgium

Re: COMatePLUS version 1.2

Post by GeBonet »

Thank you for this release :lol:
Sincerely... GeBonet
Sorry for my english :wink: ! (Windows Xp, Vista and Windows 7, Windows 10)
User avatar
captain_skank
Enthusiast
Enthusiast
Posts: 639
Joined: Fri Oct 06, 2006 3:57 pm
Location: England

Re: COMatePLUS version 1.2

Post by captain_skank »

First a little background.

Having had to use crytsal reports I needed a way to run the report from my PB app - so kludged up a command line client in vb6 as a quick n dirty way of acheiving my aim.

This works ok but is very klinky and slow so i've been wondering if i can use the crystal report conrol via pb and then I came accross comateplus.

I've had a good read or the help and a look at the examples but I'm just not getting it so before I waste to much time I thought i'd ask the expert(s) if it's actually possible to do.

Soooo, how can i convert the following simple 2 form vb app ( form1 has a button, Command1, and the code below calls form2 which has the cr viewer control on )

Private Sub Command1_Click()

Dim crApp As CRAXDRT.Application
Dim Report As CRAXDRT.Report
Dim strSelectionfrm As String
Set crApp = New CRAXDRT.Application
Set Report = crApp.OpenReport("C:\xyz\spec_master.rpt")

Form2.CrystalActiveXReportViewer1.ReportSource = Report
Form2.CrystalActiveXReportViewer1.ViewReport
Form2.Show

End Sub

the two libraries are referenced in the project Crystal ActiveX Report Viewer Library 11.5, Crystal Reports ActiveX Designer Run Time Library 11.5

I'd be really gratefull for any and all help as this will improve my app no end and make life a whole ot easier.

Thanks

captain_s
Post Reply