ComponentOne VSFlexGrid 8.0
Handling Optional Parameters in MFC

Optional parameters in COM interfaces are always of type VARIANT. To omit them in Visual Basic, you simply don't supply a value for them at all. The wrapper classes created by the MFC Wizard, however, require that you supply VARIANTS for all parameters, optional or not. In these cases, what you need to do is create a VARIANT of type VT_ERROR, and use that in place of the optional parameters.

For example, the VSFlexGrid control has an AutoSize method that takes three optional parameters. To invoke AutoSize omitting the optional parameters, you could write:

Example Title
Copy Code
  COleVariant vtNone(0L, VT_ERROR);

  m_Grid.AutoSize(1, vtNone, vtNone, vtNone);

Notice that the VARIANT is created with a 0L value instead of simply 0. This is required by the compiler to define whether the zero is a short or a long integer.

 

 


Copyright (c) GrapeCity, inc. All rights reserved.

Product Support Forum  |  Documentation Feedback