windows.h / MessageBox
-
hi ...posted a question yesterday concerning a problem with "MessageBox" Now I know where the problem is, but I don´t know how to solve it. Making a Windows Form App with VC++ .Net 2003, I add my own header file to the project. Trying to use MessageBox::Show("String") gives me an errormessage but only as long as the header file windows.h is included in the project. Is this windows.h header file incompatible with VC++ or is there any tricks I have to know? doneirik
-
hi ...posted a question yesterday concerning a problem with "MessageBox" Now I know where the problem is, but I don´t know how to solve it. Making a Windows Form App with VC++ .Net 2003, I add my own header file to the project. Trying to use MessageBox::Show("String") gives me an errormessage but only as long as the header file windows.h is included in the project. Is this windows.h header file incompatible with VC++ or is there any tricks I have to know? doneirik
Please write following details: 1) Which type of application u haev created ? (MFC/SDK) 2) what error studio flashes?
-
hi ...posted a question yesterday concerning a problem with "MessageBox" Now I know where the problem is, but I don´t know how to solve it. Making a Windows Form App with VC++ .Net 2003, I add my own header file to the project. Trying to use MessageBox::Show("String") gives me an errormessage but only as long as the header file windows.h is included in the project. Is this windows.h header file incompatible with VC++ or is there any tricks I have to know? doneirik
The Windows headers declare two versions of most APIs that take string parameters or buffers which contain strings. These typically end in either W, for a version taking Unicode (word-oriented) strings, or A, for a version taking ANSI (byte-oriented) strings. Windows 9x, in the main, only supplies the ANSI versions; Windows NT and successors (2000, XP, 2003) supply both versions. So there are actually two functions in the API:
MessageBoxA
andMessageBoxW
. For convenience the headers define a macro which, depending on whetherUNICODE
is defined, maps to the W or A version of the API. This allows Unicode and ANSI versions of the software to be compiled from the same sources just by defining or not definingUNICODE
. SoMessageBox
is a macro defined to eitherMessageBoxW
orMessageBoxA
- the former ifUNICODE
is defined and the latter if not. The C++ macro processor is dumb. It doesn't understand that you're trying to call the Windows FormsMessageBox
class'sShow
method. It just replaces the text with eitherMessageBoxW
orMessageBoxA
. This will give a compile error because there's no class with that name. I think the best thing for you to do is to isolate the .NET code in one set of source files, and the unmanaged code in another set. In the unmanaged set, includewindows.h
; in the managed files, don't. If it's in your precompiled header file, remove it. Stability. What an interesting concept. -- Chris Maunder