robert_brewington wrote:
> Wow. This is very disheartening, to say the least.
> 
> Fortunately, I have 35 years programming experience, including 10
> years with prior versions of Visual C++. This, of course, does not
> allow me to do the first thing with Visual C++ 2008.
> 
> I am trying to do something apparently extremely complicated - pop up
> a messagebox. After 3 hours, I was able to locate sample programs
> (2008 specific) at the Microsoft site, since the code snippets I find
> in the help files do not work. The Visual C++ installation did not
> load any example code.
> 
> The code in the sample program also does not work, of course. In fact,
> the sample does not even build (I am looking at something called polygon).
> 
> -------------------------------------------------------
> Option 1 - The help file shows the construct
> 
> MessageBox::Show("The calculations are complete",
>          "My Application", MessageBoxButtons::OKCancel,
>          MessageBoxIcon::Asterisk);
> 
> which leads to the errors
> 
> 1>.\BrewOrion.cpp(222) : error C2653: 'MessageBoxW' : is not a class
> or namespace name
> 1>.\BrewOrion.cpp(223) : error C2653: 'MessageBoxButtons' : is not a
> class or namespace name
> 1>.\BrewOrion.cpp(223) : error C2065: 'OKCancel' : undeclared identifier
> 1>.\BrewOrion.cpp(224) : error C2653: 'MessageBoxIcon' : is not a
> class or namespace name
> 1>.\BrewOrion.cpp(224) : error C2065: 'Asterisk' : undeclared identifier
> 1>.\BrewOrion.cpp(222) : error C3861: 'Show': identifier not found
> 
> -------------------------------------------------
> Option 2: The Polygon sample program uses
> 
> MessageBox(COLE2T(strError), _T("Error"), MB_ICONEXCLAMATION);
>                       
> which also fails - neither the _T or COLE2T words are recognized.
> 
> ------------------------------------------
> Option 3: I did manage to get this construct to pop up a message box:
> 
> MessageBox (NULL,(LPCWSTR)"Settings", (LPCWSTR)"My
> Application",MB_ICONEXCLAMATION);
> 
> Unfortunately, all the strings are in Chinese characters:(
> 
> I assume that Option 1 needs some sort of include file or namespace
> specification, although I can't find any reference to anything.
> 
> Option 2 didn't make any sense to me, since I could not find any spec
> on MessageBox that looked like this interface.
> 
> In Option 3, I am assuming LPCWSTR means use Wide Chinese characters?
> I couldn't come up with another casting type that would compile...
> 
> Any help on this would be appreciated:)
> 
> brew

Option 1 is wrong.  I've never seen that before.  Option 2 is usually 
MFC (fewer parameters than the MSDN Library specification).  Option 3 
looks more correct for a straight Win32 API call.

L = Long/Large (IIRC, this is leftover from Win 3.x)
P = Pointer
C = Const (constant)
W = Wide (Unicode)
STR = String

Or something like that.  The first thing I would check is to see if you 
are building a Unicode application.  The error message MessageBoxW() 
indicates the compiler is trying to use the Unicode version of MessageBox().

http://msdn2.microsoft.com/en-us/library/ms645505(VS.85).aspx

_T(...) is a macro that allows you to build the same app. as ANSI or 
Unicode.  In a Unicode build, the string "Settings" becomes "Settings"L 
or something like that (I can never remember where the 'L' goes - before 
or after the quotes) which tells the compiler to guarantee that it 
becomes a valid Unicode string.  I don't know why the macro isn't defined.

The 'T' you'll see in various API calls stands for TCHAR.  Depending on 
Unicode vs. non-Unicode builds, LPCTSTR will become LPCWSTR or LPCSTR.

So...to fix the code, I'd try:

MessageBox(NULL, "Settings"L, "My Application"L, MB_ICONEXCLAMATION);

Since _T() isn't available.  Although, you may simply wish to drop the 
Unicode build and stick with ANSI for the time being.  In which case, 
you can drop the 'L's.

-- 
Thomas Hruska
CubicleSoft President
Ph: 517-803-4197

*NEW* MyTaskFocus 1.1
Get on task.  Stay on task.

http://www.CubicleSoft.com/MyTaskFocus/

Reply via email to