Hi,

#ifdef FIRST1
    oPdfApp:cOption( "UseAutoSave" ) := 1 // Compiler error
#endif
#ifdef FIRST2
    oPdfApp:cOption( "UseAutoSave" , 1 )  // runtime error
#endif
//

I've used OleView.exe to see PDFCreator methods. It shows:
[id(0x68030009), propget]
HRESULT cOption([in] BSTR PropertyName, [out, retval] VARIANT*);

[id(0x68030009), propput]
HRESULT cOption([in] BSTR PropertyName, [in] VARIANT);

In current OLE implementation, messages without leading underscore call OLE using DISPATCH_PROPERTYGET | DISPATCH_METHOD, and with leading underscore using DISPATCH_PROPERTYPUT (with fall back to method containing underscore inside name, if OLE method name contains underscore itself).

The situation you presented is a lack of supported syntax in xBase world for object:method(param) := value

This can be solved by using "_" in front of method to force DISPATCH_PROPERTYPUT. So,
   oPdfApp:_cOption( "UseAutoSave" , 1 )
do the job.

I'm not sure if these lines are still valid in this case, since we have more than 1 paramter:
         dispparam.rgdispidNamedArgs = &lPropPut;
         dispparam.cNamedArgs = 1;
What is purpose of these if we define DISPATCH_PROPERTYPUT as Invoke() parameter? We need some OLE guru here.

Does anyone have a suggestion how to solve this DISPATCH_PROPERTYPUT, DISPATCH_PROPERTYGET problem using Harbour syntax. I do not like xHarbour behaviour at all. It tries to call methods in various ways: both using DISPATCH_PROPERTYGET and DISPATCH_PROPERTYPUT, both with and without underscore, thus programmer is totally out of control if he wants to assign or access a property.


// Error BASE/3012  Argument error: COPTION
// Called from WIN_OLEAUTO:COPTION(0)
// Called from SAMPLE(42)

The real error code is 0x8002000E DISP_E_BADPARAMCOUNT

It would be nice to have real OLE error code instead of 3012, but the problem is that error codes are USHORT and OLE errors are ULONG (with significant part in upper word). The similar situation is in ADS error codes. They has UNSIGNED32 type, but are small values, so no problem to cast to USHORT. Can we have ULONG (or LONG) for error subcode and OS code? It seems a simple change. hb_errRT_*() already accepts ULONG, we have to change hb_err[Get|Put]SubCode() only.


// SECOND SOLUTION:
//  use the helper object to set the value, then assign the helper object
//  to a member of the main class
    oPdfOptions:UseAutoSave :=  1   // it's ok

// BUT THEN I NEED TO ASSIGN
    oPdfApp:cOptions := oPdfOptions  // runtime error
// Error BASE/3012  Argument error: _COPTIONS
// Called from WIN_OLEAUTO:_COPTIONS(0)
// Called from SAMPLE(60)

The real error here is 0x80020003 DISP_E_MEMBERNOTFOUND

[id(0x68030007, propputref]
HRESULT cOptions([in] _clsPDFCreatorOptions* );

It seams the problem is we use DISPATCH_PROPERTYPUT instead of DISPATCH_PROPERTYPUTREF, but I completely do not know what is the difference between these and how to map Harbour syntax to OLE calls.

An easy (but I do not know if it is correct) way to solve this problem is to use DISPATCH_PROPERTYPUT | DISPATCH_PROPERTYPUTREF instead of DISPATCH_PROPERTYPUT in Invoke() call. Actually we use such technique on access: DISPATCH_PROPERTYGET | DISPATCH_METHOD. But my suggestion is a shoot in the dark.


Regards,
Mindaugas

P.S. just to summarize. Any comments on:
1) unsigned long error subcode
2) object:method(param) := value syntax
3) Harbour <-> OLE call mapping
are welcome.

_______________________________________________
Harbour mailing list (attachment size limit: 40KB)
[email protected]
http://lists.harbour-project.org/mailman/listinfo/harbour

Reply via email to