Click here to Skip to main content
15,887,245 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello this coding is based in 2008. Er, can anyone teach me how to convert in into visual 2012 version. I only know how to write in text, just add _T infront of it in DrawText.

C#
static const char* days[] = { "MON", "THU", "WED", "THR", "FRI" };



                    dc.DrawText( (days[i-1], 3, rect, DT_CENTER | DT_VCENTER | DT_SINGLELINE );



The error is here.

childview.cpp(194): error C2664: 'int CDC::DrawTextW(LPCTSTR,int,LPRECT,UINT)' : cannot convert parameter 1 from 'const char *' to 'LPCTSTR'
Posted

No, probably you did not get the purpose of _t :-).

In brief: to work with LPCTSTR, you would need to use TCHAR instead of char.

You need to understand those generic "T" types; their actual meaning is conditional, it depends on how you compile your code, as Unicode or not.

This CodeProject article provides good explanation of the matter: What are TCHAR, WCHAR, LPSTR, LPWSTR, LPCTSTR (etc.)?[^].

—SA
 
Share this answer
 
v2
Comments
Member 10446157 23-Jun-14 0:21am    
thank you! :D
Sergey Alexandrovich Kryukov 23-Jun-14 0:28am    
You are very welcome.
Good luck, call again.
—SA
You have to use TCHAR.

C#
static const char* days[] = { "MON", "THU", "WED", "THR", "FRI" };



                    dc.DrawText( (_T(days[i-1]), 3, rect, DT_CENTER | DT_VCENTER | DT_SINGLELINE );
 
Share this answer
 
Comments
Member 10446157 23-Jun-14 0:21am    
thank you!

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