COMatePLUS version 1.2

Developed or developing a new product in PureBasic? Tell the world about it.
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

Sorry Flaith I do not have OO. Try using COMate_GetLastErrorDescription() immediately after the problematic line etc.

@Mistrel : no chance! You want to create a COM dll for an in-process server then you need to roll your sleeves up and code from scratch. It is not actually very difficult once you 'bone up' on the various hoops you need to jump through. The most important part is perhaps the class factory (which is an additional component you create alongside your component) and the various accompanying functions your dll must export in order to create the class factory, register the component and determine when the dll can be unloaded by the system etc. The code dealing with your interfaces can be as straight forward as you like. Course, COMatePLUS will not be able to use your component unless you expose, at the very least, an iDispatch interface and, better yet, dual interfaces! An excellent book is "Inside COM" by Dale Rogerson; aimed at c++ users, but it is very easy to follow nevertheless. :)
Last edited by srod on Sun Apr 26, 2009 8:29 pm, edited 1 time in total.
I may look like a mule, but I'm not a complete ass.
User avatar
flaith
Enthusiast
Enthusiast
Posts: 704
Joined: Mon Apr 25, 2005 9:28 pm
Location: $300:20 58 FC 60 - Rennes
Contact:

Post by flaith »

srod wrote:Sorry Flaith I do not have OO. Try using COMate_GetLastErrorDescription() immediately after the problematic line etc.
It says "Okay" but the value is equal to "3940208" : adress value :?:

thanks srod :D
“Fear is a reaction. Courage is a decision.” - WC
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

Yes that will be the object pointer of the new object you have requested! Looks like it is working fine then!
I may look like a mule, but I'm not a complete ass.
User avatar
flaith
Enthusiast
Enthusiast
Posts: 704
Joined: Mon Apr 25, 2005 9:28 pm
Location: $300:20 58 FC 60 - Rennes
Contact:

Post by flaith »

srod wrote:Yes that will be the object pointer of the new object you have requested! Looks like it is working fine then!
Well not really, the value must be "3.1415926" and i have "3940208"

**** EDIT ****

works better with VT_STR or StrD(VT_DOUBLE(result)) :D

Code: Select all

;/////////////////////////////////////////////////////////////////////////////////
;***COMate***  COM automation through iDispatch.
;*===========
;*
;*OOo demo.
;/////////////////////////////////////////////////////////////////////////////////

IncludePath ".."
XIncludeFile "COMatePLUS.pbi"
XIncludeFile "VariantHelper_Include.pb"

Procedure.s ConvertToUrl(strFile.s)
  strFile = ReplaceString(strFile, "", "/")
  strFile = ReplaceString(strFile, ":", "|")
  strFile = ReplaceString(strFile, " ", "%20")
  strFile = "file:///" + strFile
  ProcedureReturn strFile
EndProcedure

Define.COMateObject oSM, oDesk, oCalc, oSheet, oCell

Define.safearray *openpar
Define.variant openarray
Define.variant value_pi_double
Define.d result

V_ARRAY_DISP(openarray) = safearray

V_DOUBLE(value_pi_double) = 3.1415926

oSM = COMate_CreateObject("com.sun.star.ServiceManager")
If oSM
  ;Creating instance of Desktop
  oDesk = oSM\GetObjectProperty("CreateInstance('com.sun.star.frame.Desktop')")
    If oDesk
      ;Opening a new calc Document   
      oCalc = oDesk\GetObjectProperty("loadComponentFromURL('private:factory/scalc', '_blank', 0, " + Str(openarray) + " as variant)")
      If oCalc
        oSheet = oCalc\GetObjectProperty("Sheets\getByName('Feuille1')")
        If oSheet
          oCell = oSheet\GetObjectProperty("getCellRangeByName('A3')")
          oCell\SetProperty("String = 'Hello World !' as string")

          oCell = oSheet\GetObjectProperty("getCellRangeByName('B5')")
          oCell\SetProperty("value = "+Str(value_pi_double)+" as variant")

          result = oCell\GetVariantProperty("value")

          MessageRequester("COMate PLUS", COMate_GetLastErrorDescription()+Chr(10)+"Result getCellRangeByName('B5'): " + VT_STR(result))

          oSheet\Release()
        EndIf
        oCalc\Release()
      EndIf
      oDesk\Release()   
    EndIf
  oSM\Release()
EndIf 
“Fear is a reaction. Courage is a decision.” - WC
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

Flaith, using

Code: Select all

result = oCell\GetVariantProperty("value") 
returns the address of the variant!!!

Why you are requesting a variant in this case is a bit puzzling? Once you have the variant you then have to 'look within' as you have done with your last snippet.

However, why not switch

Code: Select all

result = oCell\GetVariantProperty("value") 
for

Code: Select all

result.d = oCell\GetRealProperty("value") 
That will retrieve the double value for you. No need to explicitly deal with variants; COMatePLUS will do all that for you.
I may look like a mule, but I'm not a complete ass.
User avatar
flaith
Enthusiast
Enthusiast
Posts: 704
Joined: Mon Apr 25, 2005 9:28 pm
Location: $300:20 58 FC 60 - Rennes
Contact:

Post by flaith »

:shock: you're the best :D
“Fear is a reaction. Courage is a decision.” - WC
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

flaith wrote::shock: you're the best :D
I find that a difficult statement to disagree with! :wink:

:)
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

Post by Kiffi »

srod wrote:Kiffi you lunatic - read the manual!!! :wink:
shame on me! :oops:

Now it works like a charm and: my application works 10(!) times faster with COMatePLUS. Image

Thanks a lot! :D

Greetings ... Kiffi
Hygge
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

Shame on you indeed! :)
Kiffi wrote:Now it works like a charm and: my application works 10(!) times faster with COMatePLUS. Image

Thanks a lot! :D

Greetings ... Kiffi
As you will be aware, there is no point using a prepared statement unless you are executing it in a loop etc.

10* faster...... that is excellent! :)
I may look like a mule, but I'm not a complete ass.
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8451
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Post by netmaestro »

:shock: you're the best :D
Indeed! srod is the undisputed king of com. Excellent library 8)
BERESHEIT
User avatar
GeBonet
Enthusiast
Enthusiast
Posts: 135
Joined: Fri Apr 04, 2008 6:20 pm
Location: Belgium

Post by GeBonet »

Hi, Master of the COM
Very very good work...And I think you are the master to use and interface ActiveX and many other thing...
I hope that we will open a permanent position for the COMatePLUS (Now).
My friend was afraid to KCC when I tell him that was COMAT Obsolete ... :(
But what a joy it was to read that there was a PLUS ! :lol: :lol:

Now a more practical question: I use the example below (the top) ...
And I'd like to know how and where to use "tvwFirst #, # tvwLast, tvwNext #, # tvwPrevious"
I think it would find the next node, Previous ... But how ?

Code: Select all

;*MSComctLib_TreeCtrl demo 2 (with events!) - by ???
;*This demo may not run correctly on XP with service pack 2. This is a known issue!
;/////////////////////////////////////////////////////////////////////////////////
IncludePath "..\..\"
XIncludeFile "COMatePLUS.pbi"
Enumeration ; Relationship
  #tvwFirst
  #tvwLast
  #tvwNext
  #tvwPrevious
  #tvwChild
EndEnumeration
Define.COMateObject treeViewObject, treeNodeObject
Etc...
I would like to use this to make an application based on the "trees" ... A bit like genealogy tree... You see what i mind ?
But for this i need now where is the the father of the father and so on... And probably the good use of the relationship...

If you can point me a little, it would be nice, If not, no problem I find is a days :lol:
In any case, follow this way, its perfect ! And many thanks again ![/quote][/code] :lol:
Andi
User
User
Posts: 21
Joined: Fri Sep 12, 2008 2:43 pm
Location: Berlin

Post by Andi »

Thanks a lot, srod! Absolutely great! Your work in the field of COM is comparable to Led Zeppelin's contribution to rock music - so to speak! :lol:
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Post by ts-soft »

:D thanks for the great lib

I have a problem with the example: "Demo_AcrobatPDF.pb"
It crashes always at end :o

greetings
Thomas
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

Thanks guys, very kind of you, but remember that COMatePLUS started life as a translation of the c-DispHelper library and the ActiveX stuff is mostly the work of ts-soft and Freak. I did this partly out of necessity and partly out of a wish to learn more about COM etc. :)

@GeBonet : sorry, I have little experience with that control. Try a google search on those constants and see if you can locate some VB code etc.

@ts-soft - no crashes here. Try placing the pdfObject\Release() statement before the CloseWindow() see if that makes a difference? If not, can you try the last version of the original COMate; see if that crashes as well?
I may look like a mule, but I'm not a complete ass.
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Post by ts-soft »

srod wrote:@ts-soft - no crashes here. Try placing the pdfObject\Release() statement before the CloseWindow() see if that makes a difference?
No difference
srod wrote: If not, can you try the last version of the original COMate; see if that crashes as well?
The example doesn't crash, but included in my application, it crashes also.
The new version crashes always :cry:
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
Post Reply