4 Replies - 1257 Views - Last Post: 09 February 2010 - 12:28 PM Rate Topic: -----

#1 Sailing_Nut  Icon User is offline

  • New D.I.C Head

Reputation: 3
  • View blog
  • Posts: 17
  • Joined: 29-January 10

Strange problem in afx.h in MFC project

Posted 09 February 2010 - 07:47 AM

Hi all,

I'm having a very strange problem in an MFC project of mine. In my porject settings I have unicode use defined.

The following line of code gives me an error that it can't convert the argument types. (Not unexpected)

AfxMessageBox("Unable to read readinterval.txt");


I then changed the code adding the 'L'to make the constant string to a unicode string

AfxMessageBox(L"Unable to read readinterval.txt");



Now when I compile I get the following error:

Error 1 error C2248: 'CObject::operator =' : cannot access private member declared in class 'CObject' c:\program files\microsoft visual studio 8\vc\atlmfc\include\afx.h 1254


WTF? I'm TOTALLY confused by this!

I'll be extremely grateful for anyone to point out anything that I'm doing wrong!

This post has been edited by Sailing_Nut: 09 February 2010 - 07:49 AM


Is This A Good Question/Topic? 0
  • +

Replies To: Strange problem in afx.h in MFC project

#2 Martyn.Rae  Icon User is offline

  • The programming dinosaur
  • member icon

Reputation: 540
  • View blog
  • Posts: 1,406
  • Joined: 22-August 09

Re: Strange problem in afx.h in MFC project

Posted 09 February 2010 - 08:10 AM

If you could post the code (please stick it between
 and 
tags, we will take a look at it for you.
Was This Post Helpful? 0
  • +
  • -

#3 sarmanu  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 966
  • View blog
  • Posts: 2,362
  • Joined: 04-December 09

Re: Strange problem in afx.h in MFC project

Posted 09 February 2010 - 08:14 AM

Did you try something like that?
TCHAR str[] = _TEXT("Unable to read readinterval.txt");
AfxMessageBox(str);


More about what TCHAR does: http://msdn.microsof...y/cc842072.aspx
Was This Post Helpful? 0
  • +
  • -

#4 Sailing_Nut  Icon User is offline

  • New D.I.C Head

Reputation: 3
  • View blog
  • Posts: 17
  • Joined: 29-January 10

Re: Strange problem in afx.h in MFC project

Posted 09 February 2010 - 12:23 PM

Thanks for the suggestion! That does make things work and the message box stuff complies.

However, I was having problems in another place in my code that I did not post. It seems to be whenever I try to use a CFile object, I get the error in afx.h

I believe at this time I'm going to just ditch using the MFC file class and use the standard libraries. MFC doesn't bring enough to the table to be worth the trouble.

Thanks again!
Was This Post Helpful? 0
  • +
  • -

#5 Martyn.Rae  Icon User is offline

  • The programming dinosaur
  • member icon

Reputation: 540
  • View blog
  • Posts: 1,406
  • Joined: 22-August 09

Re: Strange problem in afx.h in MFC project

Posted 09 February 2010 - 12:28 PM

MFC was absolutely fine some ten-twelve years ago. Cutting edge stuff and I used it an awful lot back then. I haven't used it for many years now - I prefer to code directly against the windows API.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1