Visual C++

Moderators: Lundin
Number of threads: 373
Number of posts: 687

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
MessageBox Error Posted by simpulchord on 10 Sept 2009 at 11:19 PM
I am using visual studios 2005 and microsoft xp service pack 3. I was writting a simplul dialog box and I added the code for the button MessageBox("Hello")
and I got this copmile error : error C2664: 'CWnd::MessageBoxW' : cannot convert parameter 1 from 'const char [6]' to 'LPCTSTR'

Please help me with this error
Report
Re: MessageBox Error Posted by Lundin on 10 Sept 2009 at 11:37 PM
: I am using visual studios 2005 and microsoft xp service pack 3. I
: was writting a simplul dialog box and I added the code for the
: button MessageBox("Hello")
: and I got this copmile error : error C2664: 'CWnd::MessageBoxW' :
: cannot convert parameter 1 from 'const char [6]' to 'LPCTSTR'


C++ (unlike C) will not allow implicit typecasts, which may cause this problem. The problem could also be caused by the compiler using Unicode as default string type.

The best way to solve either of the 2 problems above when using Win API functions, is to use the TEXT() macro:


TEXT("Hello")
Report
Re: MessageBox Error Posted by simpulchord on 11 Sept 2009 at 4:49 AM
Thanx Lundin it works like a charm.
Report
Re: MessageBox Error Posted by simpulchord on 11 Sept 2009 at 4:50 AM
Thanx Lundin it works like a charm.
Report
Re: MessageBox Error Posted by simpulchord on 11 Sept 2009 at 4:50 AM
Thanx Lundin it works like a charm.



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.