如何将LPCTSTR字符写入内存DC中?
我想将数据写入到RECT中,然后将rect selectobject到内存DC中,然后bitblt内存中的rect,实现滚屏显示的效果,不知道思路对不对啊!!代码如下!!
nDC = CreateCompatibleDC(hDC);
SelectObject(nDC,CreateRectRgnIndirect(&MoveRect));
SIZE n_size;
GetTextExtentExPoint(hDC,_T("中"),_tcslen(_T("中")),NULL,NULL,NULL,&n_size);
n_hight = 11*n_size.cy;
MoveRect.top = 0;
MoveRect.left = 0;
MoveRect.right = rcMyBounds.right;
MoveRect.bottom = n_hight;
for(int i = 0; i<= DataNum; i++)
{
DrawText(nDC, (LPCTSTR)g_nTimeGet->UTF8ToUnicode(g_nTimeGet->allData [i].nameData).c_str(), -1, &MoveRect, DT_LEFT);
MoveRect.left = /*DRA::SCALEY(92);*/92;
DrawText(hDC, (LPCTSTR)g_nTimeGet->UTF8ToUnicode(g_nTimeGet->allData[i].newData).c_str(), -1, &MoveRect, DT_LEFT);
MoveRect.left += /*DRA::SCALEY(60);*/60;
wsprintf(szTextBuffer, TEXT("%s%\r\n%"), (LPCTSTR)g_nTimeGet->UTF8ToUnicode(g_nTimeGet->allData[i].changeData).c_str());
DrawText(hDC, szTextBuffer, -1, &MoveRect, DT_LEFT);
}
BitBlt(hDC, rcMyBounds.left, rcMyBounds.top + 18, rcMyBounds.right,rcMyBounds.bottom, nDC, 0, n_DCy, SRCCOPY);//n_DCy在WM_TIMER中n_DCy++
DeleteDC(nDC);
代码是上面的,可显示的是错误的啊!!跟们没有滚动的效果啊!!而且显示的效果根本不对啊!!
请问高手们,按照我的思路可以实现吗??如何实现!!谢谢大家,在线狂等!!
对了,项目不是MFC的项目,所以没能用到CDC等类啊!!