我的CView里面有这么一段代码,执行的时候出问题的几率很高,有一半情况显示正常,另外一半情况是显示文本有问题,文本1-文本7只显示部分,文本1、文本2、文本3后面的不显示,或者只显示文本1,后面的不显示,但是我打出的结果:所有pdc地址都没有变化,drawtext结果返回也正常,就是显示有问题,如能解决,另赠分500,请高人解答代码如下: int startx=(m_innerRect.Width() - WIDTH_OF_WAITERBK) / 2 + WIDTH_OF_LEFT;
int starty=(m_innerRect.Height() - HEIGHT_OF_WAITERBK) / 2 + HEIGHT_OF_TOP;
CFont newFont,*oldFont;
newFont.CreatePointFont(100,"仿宋体",NULL);
oldFont=pDC->SelectObject(&newFont);
//rys 2008-1-2 写当前报名人数
CRect cRect;
cRect.SetRect(startx+158,starty+40,startx+184,starty+56);
pDC->SetTextColor(RGB(0,0,0));
pDC->SetBkMode(TRANSPARENT);
CString szTemp;
nt = pDC->DrawText("文本1", &cRect, DT_CENTER);
sz.Format("%x / %x / %d", pDC, &pDC, nt);
ShowMsg(sz); cRect.SetRect(startx+96,starty+88,startx+180,starty+114);
nt = pDC->DrawText("文本2", &cRect, DT_CENTER);
sz.Format("%x / %x / %d", pDC, &pDC, nt);
ShowMsg(sz); cRect.SetRect(startx+96,starty+116,startx+180,starty+140);
nt = pDC->DrawText("文本3", &cRect, DT_CENTER);
sz.Format("%x / %x / %d", pDC, &pDC, nt);
ShowMsg(sz); szTemp.Format("%d人", m_MatchInfo.nMatchTotalPlayerNum);
cRect.SetRect(startx+96,starty+144,startx+180,starty+166);
nt = pDC->DrawText("文本4", &cRect, DT_CENTER);
sz.Format("%x / %x / %d", pDC, &pDC, nt);
ShowMsg(sz); cRect.SetRect(startx+278,starty+88,startx+368,starty+114);
nt = pDC->DrawText("文本5", &cRect, DT_CENTER);
sz.Format("%x / %x / %d", pDC, &pDC, nt);
ShowMsg(sz); cRect.SetRect(startx+278,starty+116,startx+368,starty+140);
nt = pDC->DrawText("文本6", &cRect, DT_CENTER);
sz.Format("%x / %x / %d", pDC, &pDC, nt);
ShowMsg(sz); cRect.SetRect(startx+278,starty+144,startx+368,starty+166);
nt = pDC->DrawText("文本7", &cRect, DT_CENTER);
sz.Format("%x / %x / %d", pDC, &pDC, nt);
ShowMsg(sz);
int starty=(m_innerRect.Height() - HEIGHT_OF_WAITERBK) / 2 + HEIGHT_OF_TOP;
CFont newFont,*oldFont;
newFont.CreatePointFont(100,"仿宋体",NULL);
oldFont=pDC->SelectObject(&newFont);
//rys 2008-1-2 写当前报名人数
CRect cRect;
cRect.SetRect(startx+158,starty+40,startx+184,starty+56);
pDC->SetTextColor(RGB(0,0,0));
pDC->SetBkMode(TRANSPARENT);
CString szTemp;
nt = pDC->DrawText("文本1", &cRect, DT_CENTER);
sz.Format("%x / %x / %d", pDC, &pDC, nt);
ShowMsg(sz); cRect.SetRect(startx+96,starty+88,startx+180,starty+114);
nt = pDC->DrawText("文本2", &cRect, DT_CENTER);
sz.Format("%x / %x / %d", pDC, &pDC, nt);
ShowMsg(sz); cRect.SetRect(startx+96,starty+116,startx+180,starty+140);
nt = pDC->DrawText("文本3", &cRect, DT_CENTER);
sz.Format("%x / %x / %d", pDC, &pDC, nt);
ShowMsg(sz); szTemp.Format("%d人", m_MatchInfo.nMatchTotalPlayerNum);
cRect.SetRect(startx+96,starty+144,startx+180,starty+166);
nt = pDC->DrawText("文本4", &cRect, DT_CENTER);
sz.Format("%x / %x / %d", pDC, &pDC, nt);
ShowMsg(sz); cRect.SetRect(startx+278,starty+88,startx+368,starty+114);
nt = pDC->DrawText("文本5", &cRect, DT_CENTER);
sz.Format("%x / %x / %d", pDC, &pDC, nt);
ShowMsg(sz); cRect.SetRect(startx+278,starty+116,startx+368,starty+140);
nt = pDC->DrawText("文本6", &cRect, DT_CENTER);
sz.Format("%x / %x / %d", pDC, &pDC, nt);
ShowMsg(sz); cRect.SetRect(startx+278,starty+144,startx+368,starty+166);
nt = pDC->DrawText("文本7", &cRect, DT_CENTER);
sz.Format("%x / %x / %d", pDC, &pDC, nt);
ShowMsg(sz);
2.程序中用到的几个宏都是多少?
文本1
文本2
文本3
文本4有时只显示
文本1
文本2有时全部能显示,很奇怪
很容易丢失是什么意思?什么原因会让所有画图函数失效?
pDC->SelectObject(oldFont);
newFont.DeleteObject();