The information in this article applies to:
Microsoft Visual C++ .NET (2002)
This article was previously published under Q320479
http://support.microsoft.com/default.aspx?scid=kb%3Ben-us%3B320479
A punter calls to say that the file open dialog has stopped working on his Windows 98 box, and what are you going to do about it?
Yes you tested on W2K and XP, but didn't test on W98!
When you port a Microsoft Foundation Classes (MFC) project that was created by using Microsoft Visual C++ 6.0 to Visual C++ .NET, and then you rebuild the project in Microsoft Visual Studio .NET, trusting the import wizard to to its job, the new binaries fail in different ways when you run the project on Microsoft Windows NT 4.0 or any other operating system that is still out there. When you build the project in Visual C++ 6.0, the same source files build binaries that run without error on Windows NT.
Billy screwed up!
Code generated by wizards in previous versions of Visual
C++ did not define a value for _WIN32_WINNT in Stdafx.h. New MFC projects in
Visual Studio .NET explicitly define _WIN32_WINNT to the standard 0x0400
setting, which targets the Windows NT 4.0 and later operating systems.
Conversion does not change the source files, but the new project uses the new
MFC header files for Visual C++ .NET. If _WIN32_WINNT was not explicitly defined
in the older Stdafx.h files, the included MFC headers define _WIN32_WINNT for
you.
The statement:
#include <afxwin.h>
eventually includes Afxv_w32.h. This header defines _WIN32_WINNT (if it is not already defined) to be equal to WINVER. In Visual C++ .NET, WINVER is set explicitly in Windows.h to be 0x0501. This setting targets the Microsoft Windows 2000 operating system and Microsoft Windows XP operating system, and creates structure definitions that Windows NT 4.0 and earlier do not recognize.
To work around this problem, add at least the following line of code at the beginning of the Stdafx.h file in the converted project:
#define _WIN32_WINNT 0x0400
Verify that this code is added before any MFC header files are included.
This behaviour can cause problems for any API calls that take structures that may have newer features added for newer operating systems. A common example of this problem occurs when a common dialog box does not open. For example, the OPENFILENAME structure definition has members that are recognized on Windows 2000 and later, but are not recognized on Windows NT 4.0. or on Windows 98!
I used to be able to do this sort of thing:
const BYTE * pBalls = NULL;vector<BYTE>::const_iterator pGonads = NULL;
pBalls = pGonads;
Now I get this compilation error:
error C2679: binary '=' : no operator found which takes
a right-hand operand of type 'std::vector<_Ty,_Ax>::const_iterator' (or there is
no acceptable conversion)
with
[
_Ty=BYTE,
_Ax=std::allocator<BYTE>
]
This can be got round with a:
pBalls = &(*pGonads);