Page 2 of 23
Posted: Sun Apr 26, 2009 10:14 am
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.

Posted: Sun Apr 26, 2009 11:32 am
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

Posted: Sun Apr 26, 2009 11:33 am
by srod
Yes that will be the object pointer of the new object you have requested! Looks like it is working fine then!
Posted: Sun Apr 26, 2009 2:18 pm
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))
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
Posted: Sun Apr 26, 2009 7:45 pm
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.
Posted: Sun Apr 26, 2009 7:47 pm
by flaith

you're the best

Posted: Sun Apr 26, 2009 8:12 pm
by srod
Posted: Mon Apr 27, 2009 6:54 pm
by Kiffi
srod wrote:Kiffi you lunatic - read the manual!!!

shame on me!
Now it works like a charm and: my application works
10(!) times faster with COMatePLUS.
Thanks a lot!
Greetings ... Kiffi
Posted: Mon Apr 27, 2009 7:04 pm
by srod
Shame on you indeed!
Kiffi wrote:Now it works like a charm and: my application works
10(!) times faster with COMatePLUS.
Thanks a lot!
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!

Posted: Mon Apr 27, 2009 9:11 pm
by netmaestro

you're the best
Indeed! srod is the undisputed king of com. Excellent library

Posted: Mon Apr 27, 2009 11:21 pm
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 !
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
In any case, follow this way, its perfect ! And many thanks again ![/quote][/code]

Posted: Mon Apr 27, 2009 11:48 pm
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!

Posted: Tue Apr 28, 2009 9:20 am
by ts-soft

thanks for the great lib
I have a problem with the example: "Demo_AcrobatPDF.pb"
It crashes always at end
greetings
Thomas
Posted: Tue Apr 28, 2009 10:10 am
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?
Posted: Tue Apr 28, 2009 12:22 pm
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
