我使用ActiveX控件包装了自己的一个类, 但是如何把类方法中缺省默认参数引出去?
也就是说如何在ActiveX中使用缺省的默认参数?
高手指教
3ks

解决方案 »

  1.   

    I dont know of any way you can use Class Wizard to add methods that have
    optional parameters.  The way that I created the methods was to add the
    optional parameter in the .odl.  The optional parameter needs to be of type
    VARIANT.  When VB (or anyone else) calls the function without the optional
    parameter the VARIANT will contain VARIANT.vt = VT_ERROR VARIANT.scode =
    DISP_E_PARAMNOTFOUND..idl (may be slightly different syntax in .odl) [id(1030), helpstring("method Close")] HRESULT Close([in, optional] VARIANT
    bSaveChanges, [in, optional] VARIANT strFileName);.hSTDMETHOD(Close)(THIS_ /*[in, optional]*/ VARIANT varSaveChanges, /*[in,
    optional]*/ VARIANT varFileName);.cppSTDMETHODIMP CDoc::XDoc::Close
    (
       VARIANT varSaveChanges
      ,VARIANT varFileName
    )
    {
     ....
    }Check out KB articles
    Q154039  How To Pass Optional Arguments to MFC ActiveX Controls
    Q158451  How To Call Automation Methods with Variable Argument Lists