chitra
chitra

Reputation:

How to use CWnd::CreateEx

I was using

CreateEx(

0, className, "XXX", WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN, rect, parent, 0); in Visual C++ 6.0.

when i port the same to VS 2008.., its giving an error message saying that..

error C2664: 'BOOL CWnd::CreateEx(DWORD,LPCTSTR,LPCTSTR,DWORD,const RECT &,CWnd *,UINT,LPVOID)' : cannot convert parameter 3 from 'const char [7]' to 'LPCTSTR'

how to rectify the same thanks Chitra

Upvotes: 1

Views: 2813

Answers (2)

Konrad Rudolph
Konrad Rudolph

Reputation: 545865

LPCTSTR is a typedef pointing the wide-char variant, if that's enabled (it is by default, in new versions). Just change your literals to wide-char (or better yet, use the appropriate macro to return the correct literal):

CreateEx(0, className, _T("XXX"),
    WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN, rect, parent, 0);

Upvotes: 2

Matthew Iselin
Matthew Iselin

Reputation: 10670

To directly port your old code you can turn off Unicode by right clicking on your project name, going to properties, and then changing the character set to "multibyte".

Assuming of course that your original code didn't already use Unicode...

Upvotes: 1

Related Questions