带有数组的DrawText [英] DrawText with an array

查看:139
本文介绍了带有数组的DrawText的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,这个编码基于2008年。呃,任何人都可以教我如何转换成visual 2012版本。我只知道如何用文字书写,只需在DrawText中添加_T infront。



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.

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'

推荐答案

不,可能你没有达到 _t 的目的:-)。



简而言之:使用 LPCTSTR ,你需要使用 TCHAR 而不是 char



您需要了解那些通用的T类型;它们的实际含义是有条件的,它取决于你如何编译你的代码,如果不是Unicode。



这个CodeProject文章提供了很好的解释:什么是TCHAR,WCHAR,LPSTR,LPWSTR,LPCTSTR(等等)? [ ^ ]。



-SA
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


你必须使用TCHAR。



You have to use TCHAR.

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



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


这篇关于带有数组的DrawText的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆