Need help to use PdfCreator Com
Need help to use PdfCreator Com
It is somewhere 1 sample on how to use PdfCreator Com object , I want to do a batch utility in freebasic to convert any document to pdf file.
I don't understand how to interface Com objects with freebasic
Thanks for any help
I don't understand how to interface Com objects with freebasic
Thanks for any help
Re: Need help to use PdfCreator Com
You can use disphelper to create com objects. Disphelper is included with the
fb distribution. Example of using disphelper can be found at
http://disphelper.sourceforge.net/readme.htm
And there are also some examples in the fbc distribution as well
What you need to get things going is the name of the type of object to create.
And you want the names of all the functions defined for that object type.
You can use OLE/COM Object explorer to see the interface defined by pdfcreator.exe
(to get an overview of the objects you can create and the procedures 'attached' to
that object)
http://www.softpedia.com/get/Tweak/Regi ... orer.shtml
And there is a bit of info on how to use the pdfcreator com interface in the pdfcreator
source repository
http://sourceforge.net/p/pdfcreator/cod ... rt2PDF.wbt
I am guessing fb code to create/destroy a PDFCreator object would look something like this
You should be able to use the info on PDFCreator.clsPDFCreator
as given by the object explorer to see what functions/procedures are
defined on top of an object of type PDFCreator.clsPDFCreator.
The pdfcreator repository has some examples on how to use pdfcreator.exe as a COM object
(some examples are aimed at vb6/vba/vbs users and some of the examples should
be usable). You can find the definition of the interface to the PDFCreator object there as well.
fb distribution. Example of using disphelper can be found at
http://disphelper.sourceforge.net/readme.htm
And there are also some examples in the fbc distribution as well
Code: Select all
FBC_INSTALLATION_PATH/examples/manual/libraries/disphelper1.bas
FBC_INSTALLATION_PATH/examples/manual/libraries/disphelper2.bas
FBC_INSTALLATION_PATH/examples/manual/libraries/disphelper3.bas
And you want the names of all the functions defined for that object type.
You can use OLE/COM Object explorer to see the interface defined by pdfcreator.exe
(to get an overview of the objects you can create and the procedures 'attached' to
that object)
http://www.softpedia.com/get/Tweak/Regi ... orer.shtml
And there is a bit of info on how to use the pdfcreator com interface in the pdfcreator
source repository
http://sourceforge.net/p/pdfcreator/cod ... rt2PDF.wbt
I am guessing fb code to create/destroy a PDFCreator object would look something like this
Code: Select all
#define UNICODE
#include "disphelper/disphelper.bi"
dhInitialize(TRUE)
dhToggleExceptions(TRUE)
DISPATCH_OBJ(pdfdoc)
dhCreateObject("PDFCreator.clsPDFCreator"), NULL, @pdfdoc)
''code
SAFE_RELEASE(pdfdoc)
dhUninitialize(TRUE)
as given by the object explorer to see what functions/procedures are
defined on top of an object of type PDFCreator.clsPDFCreator.
The pdfcreator repository has some examples on how to use pdfcreator.exe as a COM object
(some examples are aimed at vb6/vba/vbs users and some of the examples should
be usable). You can find the definition of the interface to the PDFCreator object there as well.
Re: Need help to use PdfCreator Com
Thank you AGS
I am starting with your code ...
But I still don't understand very well how to play with : dhCallMethod
and also how to send boolean type as parameters to functions
do you have more exemples to help , the ones in fb samples are very short
thanks again
I am starting with your code ...
But I still don't understand very well how to play with : dhCallMethod
and also how to send boolean type as parameters to functions
do you have more exemples to help , the ones in fb samples are very short
thanks again
Re: Need help to use PdfCreator Com
I am still blocked ,
how to get COM events ?
I dont understand on the VB6 / VBS exemples how they manage the event readystate ?
First attempt to play : can get the existing printer / change to PDFCreator / print test page and back again to previous printer
really need help for COM events
how to get COM events ?
I dont understand on the VB6 / VBS exemples how they manage the event readystate ?
First attempt to play : can get the existing printer / change to PDFCreator / print test page and back again to previous printer
Code: Select all
#define UNICODE
#include "disphelper/disphelper.bi"
dhInitialize(TRUE)
'dhToggleExceptions(TRUE)
DISPATCH_OBJ(pdfdoc)
dhCreateObject( "PDFCreator.clsPDFCreator", NULL, @pdfdoc)
dhToggleExceptions(TRUE)
''code
Dim AS zstring ptr szResponse
Dim AS zstring ptr szResponse2
Dim AS string szEnvoi
Dim AS zstring ptr szEmi
dhGetValue( "%s", @szResponse, pdfdoc, ".cWindowsVersion")
Print "Version: "; *szResponse
dhGetValue( "%s", @szResponse2, pdfdoc, ".cPDFCreatorApplicationPath")
Print "Chemin: "; *szResponse2
' dhGetValue("%b", boll, pdfdoc, ".cProgramIsRunning")
' Print "val: "; boll
'dhCallMethod(pdfdoc,".cStart = %s", "/NoProcessingAtStartup")
dhCallMethod(pdfdoc, ".cStart = %s", "")
'dhPutValue(pdfdoc, ".cVisible(%b)",TRUE)
'Print "cVisible"
dhGetValue( "%s", @szResponse2, pdfdoc, ".cDefaultPrinter")
Print "Actuel: "; *szResponse2
dhCallMethod(pdfdoc, ".cTestEvent(%s)","Ready")
dhPutValue(pdfdoc, ".cDefaultPrinter = %s", "PDFCreator")
dhGetValue( "%s", @szEmi, pdfdoc, ".cDefaultPrinter")
Print "Nouveau: "; *szEmi
dhCallMethod(pdfdoc, ".cPrintPDFCreatorTestpage")
Print "Test: 1"
'dhCallMethod(pdfdoc, ".cShowOptionsDialog(%b)",TRUE)
'dhCallMethod(pdfdoc,".cPrintPrinterTestpage = %s", "PDFCreator")
'Print "Test: 2"
'dhCallMethod(pdfdoc,".cPrintPrinterTestpage(%s)", "PDFCreator")
'Print "Test: 3"
dhPutValue(pdfdoc, ".cDefaultPrinter = %s", *szResponse2)
dhGetValue( "%s", @szEmi, pdfdoc, ".cDefaultPrinter")
Print "A nouveau: "; *szEmi
dhCallMethod(pdfdoc, ".cTestEvent(%s)","Ready")
dhFreeString(szResponse)
dhFreeString(szResponse2)
dhFreeString(szEmi)
sleep
dhCallMethod(pdfdoc, ".cClose")
SAFE_RELEASE(pdfdoc)
dhUninitialize(TRUE)
really need help for COM events
Re: Need help to use PdfCreator Com
I don't know whether I will be able to help you out but I'll try.
First of all: disphelper does not come with built-in support for setting up
connections between a com server and a com client (handling events).
Windows script host (and vbs) have built-in support for
setting up connections between a com server and a com object.
Using windows script host setting up a connection looks something like this
The first argument to CreateObject is the kind of object that needs to
get created. The second argument denotes the names of the functions
that implement the interface as defined by the server.
In the case of pdfcreator that interface consist of two functions.
One is called eReady and the other is called eError.
Hence the use of the functions that have names starting with the
prefix and ending with either eReady or eError (script host example).
If function_prefix would be "myprefix" then the functions that
deal with eReady and eError would be called "myprefix_eEready" and
"myprefix_eError".
Using disphelper the object gets created first. Then a connection can be
set up. The same can be done using script host
(using WScript.ConnectObject object_name, function_prefix).
To set up a connection an object called a sink is needed. That object
should get connected to the pdfcreator object. After connecting the sink
to the object the callback mechanism will work.
An article on how to set this up can be found at
http://www.codeproject.com/Articles/141 ... n-C-Part-5
It's a C tutorial which is not that convenient. But other tutorials
tend to discuss COM programming using C++ and ATL (or C++ and MFC)
which is a lot harder to understand than C.
And the tutorial at codeprojects explains COM in a way that is usable
regardless of the programming language used.
Using disphelper to set up this connection will most likely be of
little use. Or to say it in the words of the author at codeproject.com
to a server (eg connect eReady and eError to functions
found in code of the client).
From what I understand of the C tutorial this is what you need to do
(forget about using disphelper for creating the connection).
First create a vtable that can be used as a sink (the sink gets used
by the server to connect the functions eReady and eError to).
Also a unique code for the IPdfInterface has to be created
using GUIDGEN.EXE (it generates a list of numbers that should
be put in the place of /' guidgen generated numbers '/).
What follows is a 'loose' translation of the C code of the example
(code found at codeproject). I have not compiled the code and I
am pretty sure there are errors in it. But the code gives you
some insight into what is needed to get events working.
Of course you need to provide code for the functions QueryInterface, AddRef, Release
and for the eReady and eError procedures (the type of the parameter that reads byval as
IpdfInterface ptr could be wrong).
Code for QueryInterface etc...
The line that reads "hr = pdf_obj->QueryInterface etc... is what it's all about.
QueryInterface should be part of the clsPdfCreator object as it's part of any
COM object. So pdf_obj->QueryInterface should not fail (maybe an extra * is
needed at the front of pdf_obj). If hr equals 0 (after the call to QueryInterface)
then the pdf_obj has connection points. And it should be possible to hook up
the procedures IpdfInterface_Release and IpdfInterface_eReady to the PdfCreator
object. If not then there are no connection points. The windows script
host demo uses ConnectObject. ConnectObject uses connection points. So if
ConnectObject works then PdfCreator should have one or more connection point(s).
The C code continues with some more lines to set up handling of events.
Despite the code I posted I personally would not use fb and disphelper to access
a COM object. I'd use vbscript, jscript or some other scripting language. Perhaps
I'd use luaCOM (the lua --> freebasic interface is more understandable than
'low - level' COM programming).
First of all: disphelper does not come with built-in support for setting up
connections between a com server and a com client (handling events).
Windows script host (and vbs) have built-in support for
setting up connections between a com server and a com object.
Using windows script host setting up a connection looks something like this
Code: Select all
Set some_object = WScript.CreateObject("name_of_object","function_prefix")
get created. The second argument denotes the names of the functions
that implement the interface as defined by the server.
In the case of pdfcreator that interface consist of two functions.
One is called eReady and the other is called eError.
Hence the use of the functions that have names starting with the
prefix and ending with either eReady or eError (script host example).
If function_prefix would be "myprefix" then the functions that
deal with eReady and eError would be called "myprefix_eEready" and
"myprefix_eError".
Using disphelper the object gets created first. Then a connection can be
set up. The same can be done using script host
(using WScript.ConnectObject object_name, function_prefix).
To set up a connection an object called a sink is needed. That object
should get connected to the pdfcreator object. After connecting the sink
to the object the callback mechanism will work.
An article on how to set this up can be found at
http://www.codeproject.com/Articles/141 ... n-C-Part-5
It's a C tutorial which is not that convenient. But other tutorials
tend to discuss COM programming using C++ and ATL (or C++ and MFC)
which is a lot harder to understand than C.
And the tutorial at codeprojects explains COM in a way that is usable
regardless of the programming language used.
Using disphelper to set up this connection will most likely be of
little use. Or to say it in the words of the author at codeproject.com
He is talking about setting up a client so it can connectI really wish I could say that this is going to be simple and
easy-to-understand, but unfortunately, due to some dubious design
decisions by the MS guys who devised this whole scheme, it's going to
be a painfully twisted trip through the house of horrors.
to a server (eg connect eReady and eError to functions
found in code of the client).
From what I understand of the C tutorial this is what you need to do
(forget about using disphelper for creating the connection).
First create a vtable that can be used as a sink (the sink gets used
by the server to connect the functions eReady and eError to).
Also a unique code for the IPdfInterface has to be created
using GUIDGEN.EXE (it generates a list of numbers that should
be put in the place of /' guidgen generated numbers '/).
What follows is a 'loose' translation of the C code of the example
(code found at codeproject). I have not compiled the code and I
am pretty sure there are errors in it. But the code gives you
some insight into what is needed to get events working.
Code: Select all
DEFINE_GUID(DIID_IPdfInterface,/' guidgen generated numbers '/)
type IPdfInterface
dim QueryInterface as function(byval as IPdfInterface ptr, _
byval as REFIID, _
byval as any ptr ptr) as HRESULT
dim AddRef as function(byval as IPdfInterface ptr) as ULONG
dim Release as function(byval as IPdfInterface ptr) as ULONG
dim eReady as sub()
dim eError as sub()
end type
and for the eReady and eError procedures (the type of the parameter that reads byval as
IpdfInterface ptr could be wrong).
Code for QueryInterface etc...
Code: Select all
function IpdfInterface_QueryInterface(byval thiss as IPdfInterface ptr, _
byval vTableGuid as REFIID, _
byval ppv as any ptr ptr) as HRESULT
if (IsEqualIID(vTableGuid, @IID_IUnknown) = 0 andalso IsEqualIID(vTableGuid, @DIID_IPdfInterface) = 0) then
*ppv = 0
return(E_NOINTERFACE)
end if
*ppv = thiss
return(NOERROR)
end function
function IpdfInterface_AddRef(byval this as IPdfInterface ptr) as ULONG
return(1)
end function
function IpdfInterface_Release(byval this as IPdfInterface ptr) as ULONG
return(1)
end function
function IpdfInterface_eReady()
''processing
end function
function IpdfInterface_eError()
''processing
end function
''main program
sub mymain()
''first set up the interface
dim hr as HRESULT
dim cookie as DWORD
dim pdfinterface as IpdfInterface ''perhaps this should be a pointer?
pdfInterface.QueryInterface = @IpdfInterface_QueryInterface
pdfInterface.AddRef = @IpdfInterface_AddRef
pdfInterface.Release = @IpdfInterface_Release
pdfInterface.eEready = @IpdfInterface_eReady
pdfInterface.eError = @IpdfInterface_eError
''now create a clsPdfCreator object (not shown) using dhCreateObject
''
dim container as IConnectionPointContainer ptr
dim point as IConnectionPoint ptr
''if the next call fails (returns a value other than 0) then there is a problem
hr = *pdf_obj->QueryInterface(pdf_obj, @IID_IConnectionPointContainer, @container)
if (hr) then
print "could not get connection point"
else
hr = container->lpVtbl->FindConnectionPoint(container, &DIID_ICompare, "point)
container->lpVtbl->Release(container)
if (hr) then
print "Can't connect (no Iconnectionpoint object found)"
else
hr = point->lpVtbl->Advise(point, cast(IUnknown ptr,@pdfInterface), @cookie)
if (hr) then
print "Cannot connect pdfinterface to PdfCreator"
else
''do other stuff and eventually release
hr = point->lpVtbl->Unadvise(point, cookie)))
if (hr) then
print "Cannot unadvise"
else
point->lpVtbl->Release(point)
''also release the PdfCreator object
end if
end if
end if
end if
end function
QueryInterface should be part of the clsPdfCreator object as it's part of any
COM object. So pdf_obj->QueryInterface should not fail (maybe an extra * is
needed at the front of pdf_obj). If hr equals 0 (after the call to QueryInterface)
then the pdf_obj has connection points. And it should be possible to hook up
the procedures IpdfInterface_Release and IpdfInterface_eReady to the PdfCreator
object. If not then there are no connection points. The windows script
host demo uses ConnectObject. ConnectObject uses connection points. So if
ConnectObject works then PdfCreator should have one or more connection point(s).
The C code continues with some more lines to set up handling of events.
Despite the code I posted I personally would not use fb and disphelper to access
a COM object. I'd use vbscript, jscript or some other scripting language. Perhaps
I'd use luaCOM (the lua --> freebasic interface is more understandable than
'low - level' COM programming).
Re: Need help to use PdfCreator Com
Thank you for your very complete answer,
I was thinking the same way : using vbscript as prototype and perhaps switching to powerbasic and Jose Rocca tools to play directly with the Com interface.
Marc
I was thinking the same way : using vbscript as prototype and perhaps switching to powerbasic and Jose Rocca tools to play directly with the Com interface.
Marc
Re: Need help to use PdfCreator Com
try axsuite2. it has automation, direct call also event sink support. it based on jose rocca tools but in freebasic flavor:)
Re: Need help to use PdfCreator Com
To Loe
Yes I am trying with your axsuite2 tools , I'm still not understanding every thing ,
for example how to manage more than 1 parameter in a function/sub call ? the examples i've seen only have 1 parameter.
I succed to work with events , but still need your help
here first sample
Pdfcreator.bas
and the event module created with axsuite
PDF_Event.bi
Yes I am trying with your axsuite2 tools , I'm still not understanding every thing ,
for example how to manage more than 1 parameter in a function/sub call ? the examples i've seen only have 1 parameter.
I succed to work with events , but still need your help
here first sample
Pdfcreator.bas
Code: Select all
sub ready1()
Print "ready state: ok "
END SUB
sub error1()
Print "Error state: activated "
END SUB
'====================================================================
'Using ActiveX Control with AxSupport
'====================================================================
#include once "windows.bi"
'=========================================================================
'Include : ActiveX file
'=========================================================================
#Include Once "axobj.bi"
'=========================================================================
'Global variable
'=========================================================================
Dim Shared As lpunknown cal
Dim Shared As Integer calevent 'cookie for event
#Include Once "PDF_Event.bi" 'include events template
'=========================================================================
'Initial code of control
'=========================================================================
axinit(true) 'initialize axsupport with atl71 hosted ActiveX control
axcreateobject("PDFCreator.clsPDFCreator",cal) 'interface with application
__clsPDFCreator_Events_Connect(cal,calevent) ' enable application events handling
Dim AS string szResponse, defprint
dim ibool as integer
szResponse=variants(*objget(cal,"cWindowsVersion"))
Print "Version: "; szResponse
szResponse=variants(*objget(cal,"cPDFCreatorApplicationPath"))
Print "Chemin: "; szResponse
objcall cal,"cStart@1",vptr("")
ibool=variantv(*objget(cal,"cProgramIsRunning"))
if ibool<>0 THEN
print "Started val = " ; ibool
Else
print "Closed val = " ; ibool
END IF
objcall cal,"cClearCache"
szResponse=variants(*objget(cal,"cDefaultPrinter"))
defprint=szResponse
Print "DefaultPrinter: "; szResponse
ObjPut cal,"cDefaultPrinter@1",vptr("PDFCreator")
szResponse=variants(*objget(cal,"cDefaultPrinter"))
Print "DefaultPrinter: "; szResponse
objcall cal,"cTestEvent@1",vptr("Ready")
objcall cal,"cTestEvent@1",vptr("Error")
objcall cal,"cPrintPrinterTestpage@1",vptr("PDFCreator")
sleep
ObjPut cal,"cDefaultPrinter@1",vptr(defprint)
szResponse=variants(*objget(cal,"cDefaultPrinter"))
Print "DefaultPrinter: "; szResponse
sleep
objcall cal,"cClose"
ibool=variantv(*objget(cal,"cProgramIsRunning"))
if ibool<>0 THEN
print "Started val = " ; ibool
Else
print "Closed val = " ; ibool
END IF
__clsPDFCreator_Events_Disconnect(cal,calevent) 'disconnect application events
couninitialize ' stop interface to application
sleep
end
PDF_Event.bi
Code: Select all
'================================================================================
'Event - PDFCreator?{57147EB1-614D-4C2F-B657-11B481F61ABB}
'================================================================================
'================================================================================
'Event Dispatch - __clsPDFCreator ?
Const __clsPDFCreator_IID_CP="{887104EB-1F2D-404E-BC3A-572C063747D8}"
'================================================================================
'================================================================================
'Event=eReady, ID=1 ?
'================================================================================
Function __clsPDFCreator_eReady(Byval pCookie AS Events_IDispatchVtbl ptr, Byval pdispparams As DISPPARAMS ptr) As HRESULT
Dim pthis As Dword=>pCookie->pthis
'*** Put your code here ***
ready1
Function=S_OK
End Function
'================================================================================
'Event=eError, ID=2 ?
'================================================================================
Function __clsPDFCreator_eError(Byval pCookie AS Events_IDispatchVtbl ptr, Byval pdispparams As DISPPARAMS ptr) As HRESULT
Dim pthis As Dword=>pCookie->pthis
'*** Put your code here ***
error1
Function=S_OK
End Function
Function __clsPDFCreator_IDispatch_Invoke(Byval pUnk As IDispatch ptr, Byval dispidMember As DispID, Byval riid As IID ptr, _
Byval lcid As LCID, Byval wFlags As Ushort, Byval pdispparams As DISPPARAMS ptr, Byval pvarResult AS Variant ptr, _
Byval pexcepinfo As EXCEPINFO ptr, Byval puArgErr AS Uint ptr) As Hresult
If Varptr(pdispparams) Then
Select Case dispidMember
Case 1 '
Function=__clsPDFCreator_eReady(pUnk, pdispparams)
Case 2 '
Function=__clsPDFCreator_eError(pUnk, pdispparams)
Case Else
Function = DISP_E_MEMBERNOTFOUND
End Select
End If
End Function
Function __clsPDFCreator_IDispatch_QueryInterface (byval pCookie as Events_IDispatchVtbl PTR, byval riid as IID ptr, byval ppVObj as PVOID ptr) as HRESULT
Dim riids As lpolestr
StringFromIID(riid,@riids)
If (*riids="{00000000-0000-0000-C000-000000000046}") OR _
(*riids="{00020400-0000-0000-C000-000000000046}") OR _
(*riids=__clsPDFCreator_IID_CP) then
*ppvObj = pCookie
Events_AddRef(pCookie)
Function = S_OK
Else
*ppvObj = NULL
Function = E_NOINTERFACE
End IF
End Function
' --------------------------------------------------------------------------------------------
' __clsPDFCreator Events Connection function
' --------------------------------------------------------------------------------------------
Function __clsPDFCreator_Events_Connect (BYVAL pUnk AS IConnectionPointContainer ptr,dwcookie As dword) AS DWORD
Dim pCPC AS IConnectionPointContainer ptr
Dim pCP AS IConnectionPoint ptr
Dim IID_CPC AS IID ' IID_IConnectionPointContainer
Dim IID_CP AS IID ' IID_IConnectionPoint
Dim pSink AS lpunknown ' Pointer to our sink interface
Dim pdwCookie AS DWORD ' Returned token
IIDFromString("{B196B284-BAB4-101A-B69C-00AA00341D07}",@IID_CPC)
IIDFromString(__clsPDFCreator_IID_CP,@IID_CP)
AxScode = IConnectionPointContainer_QueryInterface(pUnk, @IID_CPC, @pCPC)
If AxScode <> S_OK THEN Function = AxScode:Exit Function
AxScode = IConnectionPointContainer_FindConnectionPoint(pCPC, @IID_CP, @pCP)
IConnectionPointContainer_release(pCPC)
If AxScode <> S_OK Then Function = AxScode:Exit Function
psink=Events_BuildVTbl(punk,ProcPtr(__clsPDFCreator_IDispatch_QueryInterface), ProcPtr(__clsPDFCreator_IDispatch_Invoke))
AxScode = IConnectionPoint_Advise(pCP, pSink, @pdwCookie)
dwcookie=pdwcookie
IConnectionPoint_Release(pCP)
Function = AxScode
End Function
Function __clsPDFCreator_Events_Disconnect (BYVAL pUnk AS IConnectionPointContainer ptr, byval dwcookie As dword) AS LONG
Dim pCPC AS IConnectionPointContainer ptr
Dim pCP AS IConnectionPoint ptr
Dim IID_CPC AS IID ' IID_IConnectionPointContainer
Dim IID_CP AS IID ' IID_IConnectionPoint
If pUnk = 0 Then Function = E_POINTER : Exit Function
IIDFromString("{B196B284-BAB4-101A-B69C-00AA00341D07}",@IID_CPC)
IIDFromString(__clsPDFCreator_IID_CP,@IID_CP)
AxScode = IConnectionPointContainer_QueryInterface(pUnk, @IID_CPC, @pCPC)
If AxScode <> S_OK Then Function = AxScode : Exit Function
AxScode = IConnectionPointContainer_FindConnectionPoint(pCPC, @IID_CP, @pCP)
IConnectionPointContainer_release(pCPC)
If AxScode <> S_OK Then Function = AxScode : Exit Function
AxScode = IConnectionPoint_Unadvise(pCP, dwcookie)
IConnectionPoint_Release(pCP)
Function = AxScode
End Function
Re: Need help to use PdfCreator Com
to manage multiple variable in axsuite automation you just have to follow number of parameter passing after @.
syntax:
xface,"prop1@1.prop2@2.propN@3",v1,v2,v3,v4,v5,v6
you see @1,@2,@3 mean you will passing 6 parameter.
syntax:
xface,"prop1@1.prop2@2.propN@3",v1,v2,v3,v4,v5,v6
you see @1,@2,@3 mean you will passing 6 parameter.
Re: Need help to use PdfCreator Com
Thanks again loe
In fact, it is what i am doing , my problem is to send a variant value byval as it is needed by pdfcreator
see : Public Property Let cOption(ByVal PropertyName As String, ByVal value As Variant)
it works ok for the 1st parameter, but impossible to get the 2nd in pdfcreator
like that :
nor like that :
nor like that :
with numeric or string value put into a variant type i did not succed ; and pdfcreator needs variant type.
any idea ? ByVal problem with variants ? because with direct type : string , boolean, numeric value it works...
In fact, it is what i am doing , my problem is to send a variant value byval as it is needed by pdfcreator
see : Public Property Let cOption(ByVal PropertyName As String, ByVal value As Variant)
it works ok for the 1st parameter, but impossible to get the 2nd in pdfcreator
like that :
Code: Select all
ObjPut cal, "cOption@2", vptr( "UseAutosaveDirectory"),vptr(1)
Code: Select all
ObjPut cal, "cOption@2", vptr( "UseAutosaveDirectory"),vptr(vlet(1))
Code: Select all
ObjPut cal, "cOption@2", vptr( "UseAutosaveDirectory"),@vlet(1)
any idea ? ByVal problem with variants ? because with direct type : string , boolean, numeric value it works...
Re: Need help to use PdfCreator Com
Which VARIANT type are you using, is it declared as simple structure or does it have a constructor/destructor? If it does, then the VARIANT will be passed BYREF even if BYVAL was given following the GCC ABI. In that case the solution is to use a VARIANT type without constructor/destructor (for example, from FreeBASIC/examples/win32/variants/variant.bi, use the VARIANT_ type declared there, instead of the VARIANT type).
See also: http://www.freebasic.net/forum/viewtopi ... =6&t=19518
Note that Byval As String is currently working like Byval As Zstring Ptr but that may change in future versions of FB, so if you want to pass a char* then it'd be better to use Byval As Zstring Ptr immediately.
See also: http://www.freebasic.net/forum/viewtopi ... =6&t=19518
Note that Byval As String is currently working like Byval As Zstring Ptr but that may change in future versions of FB, so if you want to pass a char* then it'd be better to use Byval As Zstring Ptr immediately.
Re: Need help to use PdfCreator Com
yups you can not pass parameter byval in axsuite.
I don't recall if I have defined variant type,
I didn't touch any programming since I got cancer about 2 years ago. I'll see it what I can do:)
I don't recall if I have defined variant type,
I didn't touch any programming since I got cancer about 2 years ago. I'll see it what I can do:)
Re: Need help to use PdfCreator Com
ok, as dkl said you can define variable as variant_. then pass it pointer to axsuite.
dim shared vvar as variant_
then define it as variant type variant
you can then pass it pointer to axsuite.
xface,"prop@1",@vvar
dim shared vvar as variant_
then define it as variant type variant
you can then pass it pointer to axsuite.
xface,"prop@1",@vvar
Re: Need help to use PdfCreator Com
to loe
with axsuite
i've never succed to send a 2nd parameter as variant as needed by pdfcreator
> Public Property Let cOption(ByVal PropertyName As String, ByVal value As Variant)
using types : variant , variant_ or just simple basic udt with 16 bytes
like that :
i don't understand because it works very easy using disphelper
like that :
my intention was to use axsuite because it supports event handling : important to know the states ready or error,
but i have to stay with disphelper without managing event states .... more complicated to follow the pdfcreator process, at least until i find the solution to send that variant parameter as second parameter option
probably i am just bright for that :(
with axsuite
i've never succed to send a 2nd parameter as variant as needed by pdfcreator
> Public Property Let cOption(ByVal PropertyName As String, ByVal value As Variant)
using types : variant , variant_ or just simple basic udt with 16 bytes
like that :
Code: Select all
TYPE fvariant
ftype As ushort
freserved1(0 to 5) as byte
fdata1 as uinteger
fdata2 as uinteger
END TYPE
dim variant_udt as fvariant
variant_udt.ftype =3
variant_udt.fdata1= 1
ObjPut cal, "cOption@2", vptr( "AutosaveFormat"),@variant_udt
like that :
Code: Select all
dhPutValue(pdfdoc, ".cOption (%s ,%d)", "UseAutosave", 1)
but i have to stay with disphelper without managing event states .... more complicated to follow the pdfcreator process, at least until i find the solution to send that variant parameter as second parameter option
probably i am just bright for that :(
Re: Need help to use PdfCreator Com
try this
btw in disphelper what it mean of %d ? if it work it will explain type of variant.
Code: Select all
dim as variant vvar1,vvar2
vlet(vvar1,1) 'assign a value to variant
vlet(vvar2,vvar1) 'assign variant to variant
'if it boolean you can assign it as vlet(vvar1,true)
objput cal,"coption@2",vptr("autosaveformat"),@vvar2