Click here to Skip to main content
15,878,543 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
MFC_Tutorial_Window()     {         Create(NULL,"MFC Tutorial Part 1 CoderSource Window");     }

in my project the second argument create problem and i am getting error like
cannot convert parameter 2 from 'const char [39]' to 'LPCTSTR'

What I have tried:

i dont have any idea to do but if i change the second argument of Create() to null it works. but i need title of the window.
Updated 8-Aug-18 9:10am

You have set your project to build a Unicode application (which is the default).

For such all string literals have to be Unicode (wide char) strings which requires prefixing them with an L:
MFC_Tutorial_Window() { Create(NULL, L"MFC Tutorial Part 1 CoderSource Window");     }

If you want to support non Unicode builds too, you can use the _T() macro for such strings which is then resolved according to the project settings:
MFC_Tutorial_Window() { Create(NULL, _T("MFC Tutorial Part 1 CoderSource Window")); }
Share this answer
CPallini 8-Aug-18 15:08pm    
Welcome to the Macrosoft Nightmare.
Have a look at this CodeProect's article: What are TCHAR, WCHAR, LPSTR, LPWSTR, LPCTSTR (etc.)?[^]
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900