Click here to Skip to main content
15,922,696 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralSendInput / keybd_event Pin
12-Aug-01 23:11
suss12-Aug-01 23:11 
QuestionA question about CTreeCtrl??? Pin
12-Aug-01 22:24
suss12-Aug-01 22:24 
GeneralATL / Events Pin
12-Aug-01 22:03
suss12-Aug-01 22:03 
Questionhow to do this, some advice please Pin
Kuniva12-Aug-01 21:38
Kuniva12-Aug-01 21:38 
AnswerRe: how to do this, some advice please Pin
12-Aug-01 22:08
suss12-Aug-01 22:08 
AnswerRe: how to do this, some advice please Pin
Steen Krogsgaard13-Aug-01 2:43
Steen Krogsgaard13-Aug-01 2:43 
GeneralC++ data type. Pin
12-Aug-01 21:29
suss12-Aug-01 21:29 
GeneralRe: C++ data type. Pin
Derek Waters12-Aug-01 21:41
Derek Waters12-Aug-01 21:41 
You were on the right track. VARIANTs are the type to use. In fact, they're the type that VB's Variants are based on. You can use them as parameters to functions (and you'll find you have to for many COM calls):

void MyFunction(VARIANT avtSomeValue)
{
   switch (avtSomeValue.vt)
   {
   case VT_I4:
      // This is an int.
   ...etc
}


There is also a wrapper class called _variant_t which allows you to create MOST VARIANT types (unfortunately not all), and also provides a method called ChangeType which can be used to change the type of the variant. Personally, I find it easier to create the _variant_t objects as I need them:

if (i_want_a_string)
{
   _variant_t vvtString("Some String");
   MyFunction(vvtString);
}
else if (i_want_an_int)
{
   _variant_t vvtInt(123, VT_I4);
   MyFunction(vvtInt);
}
else
{
   _variant_t vvtFloat(123.456, VT_R8);
   MyFunction(vvtFloat);
}


There are also a whole pile of API functions which can help manipulate and convert VARIANTs. Try looking in MSDN for VarI4FromBstr or similarly named functions. There are also comparison functions such as VarCmp.

Hope this helps.

------------------------
Derek Waters
derek@lj-oz.com
GeneralRe: C++ data type. Pin
13-Aug-01 0:00
suss13-Aug-01 0:00 
GeneralRe: C++ data type. Pin
KingsGambit13-Aug-01 1:22
KingsGambit13-Aug-01 1:22 
Generalobtain voice samples algo/code Pin
argonaut12-Aug-01 20:51
argonaut12-Aug-01 20:51 
GeneralRe: obtain voice samples algo/code Pin
12-Aug-01 22:09
suss12-Aug-01 22:09 
GeneralShell Extentions / EXPLORER Extentions Pin
12-Aug-01 19:59
suss12-Aug-01 19:59 
QuestionHow to Disable Resizing Windows? Pin
12-Aug-01 17:03
suss12-Aug-01 17:03 
AnswerRe: How to Disable Resizing Windows? Pin
Christian Graus12-Aug-01 17:09
protectorChristian Graus12-Aug-01 17:09 
AnswerRe: How to Disable Resizing Windows? Pin
Michael Dunn12-Aug-01 19:31
sitebuilderMichael Dunn12-Aug-01 19:31 
GeneralPlease Help Me! Need to know how to do Sprites! Pin
Journeyman12-Aug-01 15:02
Journeyman12-Aug-01 15:02 
GeneralRe: Please Help Me! Need to know how to do Sprites! Pin
Christian Graus12-Aug-01 16:16
protectorChristian Graus12-Aug-01 16:16 
GeneralRe: Please Help Me! Need to know how to do Sprites! Pin
PJ Arends12-Aug-01 21:28
professionalPJ Arends12-Aug-01 21:28 
GeneralMicrosoft Visual Runtime Library Error Pin
Keith Avery12-Aug-01 12:07
Keith Avery12-Aug-01 12:07 
GeneralRe: Microsoft Visual Runtime Library Error Pin
Christian Graus12-Aug-01 12:50
protectorChristian Graus12-Aug-01 12:50 
GeneralRe: Microsoft Visual Runtime Library Error Pin
Keith Avery12-Aug-01 22:01
Keith Avery12-Aug-01 22:01 
GeneralPlease help with some buttons in Doc/View structure... Pin
12-Aug-01 11:50
suss12-Aug-01 11:50 
GeneralRe: Please help with some buttons in Doc/View structure... Pin
12-Aug-01 22:12
suss12-Aug-01 22:12 
QuestionSetSelectionMark() <- How does it work? Pin
Sprudling12-Aug-01 9:39
Sprudling12-Aug-01 9:39 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.