MFC and Direct3d - Multiple BSTR definitions

MFC and Direct3d - Multiple BSTR definitions

Post by Chris Willia » Mon, 14 Oct 1996 04:00:00



Howdy all,

I'm attempting to use Direct3d retained mode in an MFC MDI
application.    If I include the d3drmwin.h file with the stdafx.h I
receive a compile error stating that BSTR is being redefined
differently than its original definition.   Defining
_AFX_NO_BSTR_SUPPORT gets rid of the message, but I have no idea of
the possible side-effects this may have.

Are there any gotchas with this approach?   Is there a better way to
do this?

Thanks for taking the time to read

Chris W
Canberra, Australia

Welcome to the information goat track.

 
 
 

MFC and Direct3d - Multiple BSTR definitions

Post by P.J. Tezz » Tue, 15 Oct 1996 04:00:00




Quote:> Howdy all,

> I'm attempting to use Direct3d retained mode in an MFC MDI
> application.    If I include the d3drmwin.h file with the stdafx.h I
> receive a compile error stating that BSTR is being redefined
> differently than its original definition.   Defining
> _AFX_NO_BSTR_SUPPORT gets rid of the message, but I have no idea of
> the possible side-effects this may have.

> Are there any gotchas with this approach?   Is there a better way to
> do this?

As long as you understand that all 32 bit OLE/COM interfaces use UNICODE
BSTR's things will probably be alright. Older versions of MFC tried to hide
this fact from you by wrapping all UNICODE interfaces with ANSI wrapper
classes whose job was to convert ANSI strings to UNICODE, call the actual
UNICODE method, then convert any returned UNICODE strings back to ANSI.
This approach was slow, clunkey, and caused problems such as your
(conflicting ANSI and UNICODE definitions of BSTRs). Starting with VC 4.0,
the UNICODE interfaces are used directly (see the docs for details). If you
are not using BSTRs in your application, then this mismatch will not bother
you. If you are, you should upgrade to VC 4.x, and figure out how to use
CStrings (wide character constructor and CreateSysString member function)
and the USES_CONVERSION family of macros to convert between ANSI and
UNICODE as required to call OLE interfaces.