943,645 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 5503
  • C++ RSS
Oct 22nd, 2008
0

AFXMessageBox

Expand Post »
I would like to insert a function AFXMessageBox in generic class, but the compiler said this "error C2665: 'AfxMessageBox' : none of the 2 overloads can convert parameter 1 from type 'char [30]'"
.
I have de same code in oder project type CDialog and i haven't any error
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
morais is offline Offline
1 posts
since Oct 2008
Oct 22nd, 2008
0

Re: AFXMessageBox

This board is for introductions only. Moved to C forum.
Moderator
Featured Poster
Reputation Points: 1764
Solved Threads: 574
Moderator
jbennet is offline Offline
16,485 posts
since Apr 2005
Oct 22nd, 2008
0

Re: AFXMessageBox

Post the line of code that caused that error because I'm not a mind reader or clairvoyant.
Sponsor
Team Colleague
Featured Poster
Reputation Points: 5608
Solved Threads: 2282
Retired and Enjoying Life
Ancient Dragon is offline Offline
21,947 posts
since Aug 2005
Oct 22nd, 2008
0

Re: AFXMessageBox

I suppose you are using Visual C++. From the little info that you give, you seem to be calling the function AfxMessageBox, but passing parameter that does not match its declaration.

We need to see the codes where you call this function, and the full error message (your error message says "convert parameter 1 from type 'char [30]", but did not mention to which type?).
Reputation Points: 118
Solved Threads: 15
Posting Pro in Training
Denniz is offline Offline
428 posts
since Sep 2008
Oct 23rd, 2008
0

Re: AFXMessageBox

AfxMessageBox requires a LPCTSTR but you pass an array of char[30] as a parameter.

C++ Syntax (Toggle Plain Text)
  1. char str[30] = "Hello world!";
  2. AfxMessageBox(&x[0]);

works without any problems (in a non-Unicode project).
Last edited by jencas; Oct 23rd, 2008 at 6:47 am.
Reputation Points: 395
Solved Threads: 71
Posting Whiz
jencas is offline Offline
362 posts
since Dec 2007
Oct 23rd, 2008
0

Re: AFXMessageBox

or for UNICODE
C++ Syntax (Toggle Plain Text)
  1. TCHAR str[] = _TEXT("Hello world!");
  2. AfxMessageBox(x);
Last edited by Ancient Dragon; Oct 23rd, 2008 at 7:50 am.
Sponsor
Team Colleague
Featured Poster
Reputation Points: 5608
Solved Threads: 2282
Retired and Enjoying Life
Ancient Dragon is offline Offline
21,947 posts
since Aug 2005

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: MAPI
Next Thread in C++ Forum Timeline: Expert Help Needed Plz................URGENT





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC