Log in

View Full Version : Pls Hlp: eVC++ MFC App, MessageBox on button click, wont build..


PPCdev
02-08-2003, 12:08 AM
Friends, Im a *super newbie* to both eVC and C++, so pls bare with me.

Working on my first newbie eVC++ project, a simple MFC app with a text box and a command button.

I want a message box to pop up when the command button is tapped, heres my snippit..

void CTest05Dlg::OnButton1()
{

MessageBox("Help, Something went wrong.", "Error", MB_ICONERROR | MB_OK);

}


However, it wont compile.. I cant get it to build.

Im *super new* to eVC++, learning C++ and the IDE at the same time so my learning curve will be slow.

Thanks for any help-
Andrew

Kati Compton
02-08-2003, 12:42 AM
Try wrapping both strings in _T().

So it would be:

MessageBox(_T("Help, Something went wrong."), _T("Error"), MB_ICONERROR | MB_OK);

Alternately, you can use the TEXT() macro instead of _T().

It has to do with the fact that PocketPC (at least 2002) requires Unicode strings rather than ASCII strings, and the macro converts an ASCII string to Unicode.

FYI: For future questions, copy the error you're getting into the message - it makes it easier for people to understand what's going on.

PPCdev
02-08-2003, 02:10 AM
Thanks! That worked! Ill try to remember to be more specific with error messages in the future.

As I said, Im still learning the IDE and 'C' at the same time, being a fluent VB programmer means very little with eVC. :-)