DOC: defaultvalue Attribute Doesn't Work for MFC dispinterface Server and VB ClientID: Q216334
|
The defaultvalue attribute is only supported for named parameters or VARIANT parameters in MFC automation server.
The MFC documentation does not clearly state that the defaultvalue attribute is not supported for parameters of VARTYPE when using dispinterface (or the default implementation of MFC automation server).
Actually, the typelibrary generated by MFC always contains the optional attribute together with the defaultvalue attribute, while the optional attribute is suppose to work only with VARIANT, but defaultvalue can also be present without the optional attribute, and defaultvalue should work for any VARTYPE. This article clarifies this situation.
short Test(short iVal)
[id(1)] short Test([in, defaultvalue(99)] short iVal);
DECLARE_OLECREATE(Cdfvbug) //Add this line to Dfvbug.h.
IMPLEMENT_OLECREATE(Cdfvbug, _T("testdfv.dfvbug"), 0x63b80a5c,0xb7c8, 0x11d2, 0xb7, 0xb, 0x0, 0xc0, 0x4f, 0x96, 0xc7, 0xb5) //Add this line to Dfvbug.cpp (using your own guid).
Private Sub Form_Load()
Dim obj As Object
Set obj = CreateObject("Testdfv.dfvbug")
Text2.Text = obj.Test
End Sub
For additional information about a method to replace the default implementation of any MFC automation server, please see the following article in the Microsoft Knowledge Base:
Q140616 SAMPLE: MFCDISP: Replacing MFC IDispatch Implementation
Additional query words: defaultvalue dispinterface
Keywords : kbdocfix kbMFC kbVS600 kbVS600sp2fix kbVS600SP1fix
Version : WINDOWS:6.0,6.0 SP1,6.0 SP2
Platform : WINDOWS
Issue type :
Last Reviewed: May 20, 1999