Build Application in VC++
-
I Want to Build Application in VC++ (dialog): void CFirstVCDlg::OnHello() { MessageBox("This is my first Visual C++ Application!"); } Why error is showed?: error C2664: 'CWnd::MessageBoxW' : cannot convert parameter 1 from 'const char [41]' to 'LPCTSTR' thank you
thank you soso
-
I Want to Build Application in VC++ (dialog): void CFirstVCDlg::OnHello() { MessageBox("This is my first Visual C++ Application!"); } Why error is showed?: error C2664: 'CWnd::MessageBoxW' : cannot convert parameter 1 from 'const char [41]' to 'LPCTSTR' thank you
thank you soso
You might be using unicode build( which is default in vs2005 and later ). so should pass unicode string to
MessageBox()
function. To convert your string to unicode. use_T
macro.MessageBox( _T("This is my first Visual C++ Application!"));
-
I Want to Build Application in VC++ (dialog): void CFirstVCDlg::OnHello() { MessageBox("This is my first Visual C++ Application!"); } Why error is showed?: error C2664: 'CWnd::MessageBoxW' : cannot convert parameter 1 from 'const char [41]' to 'LPCTSTR' thank you
thank you soso
Try using
MessageBox(_T("This is my first Visual C++ Application!"));
it should work
-
I Want to Build Application in VC++ (dialog): void CFirstVCDlg::OnHello() { MessageBox("This is my first Visual C++ Application!"); } Why error is showed?: error C2664: 'CWnd::MessageBoxW' : cannot convert parameter 1 from 'const char [41]' to 'LPCTSTR' thank you
thank you soso
You are building for Unicode and therefore trying to pass an ANSI string to an API which expects an Unicode string. Include all your literal strings within the TEXT macro.
anassamar wrote:
MessageBox("This is my first Visual C++ Application!");
MessageBox(_T("This is my first Visual C++ Application!")); The
_T
macro automatically emits an ANSI or an Unicode string (by prefixing nothing if building forMBCS
or by prefixingL
to the literal string if building for Unicode) These links may help you further to understand about string data types: The Complete Guide to C++ Strings, Part I - Win32 Character Encodings[^] The Complete Guide to C++ Strings, Part II - String Wrapper Classes[^] This might help you with International programming and Unicode: International programming[^]It is a crappy thing, but it's life -^ Carlo Pallini
-
Try using
MessageBox(_T("This is my first Visual C++ Application!"));
it should work
-
I Want to Build Application in VC++ (dialog): void CFirstVCDlg::OnHello() { MessageBox("This is my first Visual C++ Application!"); } Why error is showed?: error C2664: 'CWnd::MessageBoxW' : cannot convert parameter 1 from 'const char [41]' to 'LPCTSTR' thank you
thank you soso
推荐网站www.codeproject.com 和 www.codeguru.com,在这里可以找到