小女子大胆的在学winAPI,又遇到问题,好怪,请教各位大侠... 改成UnicodenWords如果是奇数,就会有乱码 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 谢谢xingxingxing, 不过请问如何改为Unicode? 我的文本里用了TEXT("..."),它不是改为了宽字符吗?? for(i=0;i<nLines;i++) TextOut(hdc,0,i*cyChar,szBuffer + i * nWords, nWords); //这里可能会将汉字切断,因为一个汉字是两个字节 TextOut(hdc,0,i*cyChar,szBuffer + i * nWords, nLen - i*nWords); 另外,我也试过把nWords=xWnd/cxChar;改为:nWords=(xWnd%cxChar ? xWnd/cxChar : xWnd/cxChar - 1);以确保nWord为偶数,也不行哦,还是出现乱码...怪... to vcmute(横秋):如何解决呢?? nStart = 0; //显示文本 for(i=0;i<nLines;i++) { nCurLen =0; while(nCurLen<nWords)nCurLen+=szBuffer[nStart+nCurLen]&0x80?2:1; TextOut(hdc,0,i*cyChar,szBuffer + nStart, nCurLen); nStart += nCurLen; } //剩下不够一行的字符最后输出 TextOut(hdc,0,i*cyChar,szBuffer + nStart, nLen - nStart);>请问如何改为Unicode? 我的文本里用了TEXT("..."),它不是改为了宽字符吗??TEXT并不会自己转宽字符,要根据是否定义_UNICODE宏来决定使用哪种字符 VS2003 可能默认定义了 _UNICODE宏 用GetTextExtentExPoint好用点i =0;nStart = 0;//显示文本while(nStart<nLen){ SIZE sz; GetTextExtentExPoint(hdc,szBuffer+nStart,nLen-nStart,xWnd,&nCurLen,NULL,&sz); TextOut(hdc,0,cyChar*i++,szBuffer + nStart, nCurLen); nStart += nCurLen;} vcmute(横秋)的这行while(nCurLen<nWords)nCurLen+=szBuffer[nStart+nCurLen]&0x80?2:1;的szBuffer[nStart+nCurLen]&0x80?2:1 这句好像很妙,不过我还没看懂,不过,我在开头定义unicode:#define UNICODE#include <windows.h>就可以的哦 Project -> Settings -> C/C++ -> Preprocessor DefinitionsAdd UNICODE Definition. 摆托,不管你是男是女,不要以小女子开头,有问题直接问就是了,非要加个这玩意,到时候满CSDN都是小女子请教美女学编程的问题小妹请教各位大哥女程序员的问题............................... 我在VS2003中运行代码,窗口弹出片刻后又错误提示“Run-Time Check Failure #3 - The variable 'xWnd' is being used without being defined.“,就是nWords=xWnd/cxChar; //一行能显示的字数是怎么回事? 敢问高手 CSimpleArray如何在VC6中使用 编译DLL的问题 MouseProc函数的一些问题 【求】放大、缩小、手形ico图片三张 MFC 能像C++ 那样支持接口吗? interface 这个哪里错了。。 MemDc是否有大小限制,memdc是否可以自已控制开辟内存的大小 求助软件效能改进 VC中用FindResource如何加载JPEG类型的资源。 问个线程基础问题 熟悉c++,想学mfc编程,看什么书比较好
请问如何改为Unicode? 我的文本里用了TEXT("..."),它不是改为了宽字符吗??
TextOut(hdc,0,i*cyChar,szBuffer + i * nWords, nWords);
//这里可能会将汉字切断,因为一个汉字是两个字节
TextOut(hdc,0,i*cyChar,szBuffer + i * nWords, nLen - i*nWords);
nWords=xWnd/cxChar;
改为:
nWords=(xWnd%cxChar ? xWnd/cxChar : xWnd/cxChar - 1);
以确保nWord为偶数,也不行哦,还是出现乱码...
怪...
如何解决呢??
//显示文本
for(i=0;i<nLines;i++)
{
nCurLen =0;
while(nCurLen<nWords)nCurLen+=szBuffer[nStart+nCurLen]&0x80?2:1;
TextOut(hdc,0,i*cyChar,szBuffer + nStart, nCurLen);
nStart += nCurLen;
}
//剩下不够一行的字符最后输出
TextOut(hdc,0,i*cyChar,szBuffer + nStart, nLen - nStart);>请问如何改为Unicode? 我的文本里用了TEXT("..."),它不是改为了宽字符吗??TEXT并不会自己转宽字符,要根据是否定义_UNICODE宏来决定使用哪种字符
i =0;
nStart = 0;
//显示文本
while(nStart<nLen)
{
SIZE sz;
GetTextExtentExPoint(hdc,szBuffer+nStart,nLen-nStart,xWnd,&nCurLen,NULL,&sz);
TextOut(hdc,0,cyChar*i++,szBuffer + nStart, nCurLen);
nStart += nCurLen;
}
vcmute(横秋)的这行
while(nCurLen<nWords)nCurLen+=szBuffer[nStart+nCurLen]&0x80?2:1;
的szBuffer[nStart+nCurLen]&0x80?2:1 这句好像很妙,不过我还没看懂,不过,我在开头定义unicode:
#define UNICODE
#include <windows.h>
就可以的哦
Add UNICODE Definition.
到时候满CSDN都是小女子请教美女学编程的问题小妹请教各位大哥女程序员的问题...............................
nWords=xWnd/cxChar; //一行能显示的字数是怎么回事?