Jose's Read Only Forum 2023

IT-Consultant: José Roca (PBWIN 10+/PBCC 6+) (Archive only) => Discussion => Topic started by: Frederick J. Harris on January 12, 2012, 10:37:45 PM

Title: Discrepancies In IDL And And Usage Of Excel's Visible Property
Post by: Frederick J. Harris on January 12, 2012, 10:37:45 PM
The Excel dual interface ...

interface _Application : IDispatch

...contains a propget and propput method 'Visible' to either get or set the visibility of a running instance
of Excel.  Here is the IDL from OLEVIEW ...


[id(0x0000022e), propget, helpcontext(0x0001022e)] HRESULT Visible([in, lcid] long lcid, [out, retval] VARIANT_BOOL* RHS);
[id(0x0000022e), propput, helpcontext(0x0001022e)] HRESULT Visible([in, lcid] long lcid, [in] VARIANT_BOOL RHS);


Note that the first parameter, that is, the LCID, isn't marked as optional in any way that I can see, and indeed, Jose's
typelib browser lists it like so...



'=====================================================================================
PROPERTY GET Visible <558> ( _                       ' VTable offset = 1128
  BYVAL prm_lcid AS LONG _                           ' [in] lcid VT_I4 <Long>
) AS INTEGER                                         ' [retval][out] *RHS VT_BOOL <Integer>
' =====================================================================================
PROPERTY SET Visible <558> ( _                       ' VTable offset = 1132
  BYVAL prm_lcid AS LONG _                           ' [in] lcid VT_I4 <Long>
, BYVAL prm_RHS AS INTEGER _                         ' [in] RHS VT_BOOL <Integer>
)                                                    ' void
' =====================================================================================


However, using Jose's typelib browser or the PowerBASIC COM browser when configured to create ID Binding IDBIND
interfaces, the LCID doesn't show up...



MEMBER GET  Visible <558> () AS INTEGER
MEMBER LET  Visible <558> ()   ' Parameter Type AS INTEGER

Interface IDBind XL_Application 
  ...                       
  Member Get Visible <558> () As Integer
  Member Let Visible <558> (In RHS As Integer<1>)           
  ...
End Interface


Indeed, it can't be used as far as I can tell.  Over the years I've made countless calls on this method with PowerBASIC
and never used that 1st parameter.  I never even noticed it was there.  Just today while working with C++ code and doing
IDispatch::Invoke() calls I have been unable to get the call to work if I use two parameters to the propput method, the
first being the LCID and the second a boolean for setting the visibility.  It simply refuses to work and my HRESULT is
DISP_E_BADPARAMCOUNT or DISP_E_MEMBERNOTFOUND depending on various settings I'm using.  Can someone explain
to me what is going on here?  I don't understand it at all.  Now I fully understand that setting a property should just require
the single parameter being set, and I don't think the concept of true or false in binary is appreciably affected by a person's
language or nationality, but my typelib code I'm generating is coming up with those two parameters for the simple reason
that they are indeed in the TypeLib.





Title: Re: Discrepancies In IDL And And Usage Of Excel's Visible Property
Post by: Dominic Mitchell on January 12, 2012, 11:57:09 PM
You should group by "type kind" in OLEVIEW and compare the results for Interfaces and Dispinterfaces.
The definitions of a few methods in some interfaces that are marked as dual are inconsistent.
Using direct interface calls with Excel, in my opinion, is not a good idea.