求救:
诸位高人,我用VC制作一个图表控件,控件中图的逻辑幅面较大,控件的父类是CWND,下面是绘图函数:
void CChartCtl::OnPaint()
{
CPaintDC dc(this); // device context for painting
// TODO: Add your message handler code here
if(m_bShowData)
OnDraw(&dc);
// Do not call CWnd::OnPaint() for painting messages
}
void CChartCtl::OnDraw(CDC *pDC)
{
// CDC MemDC;
if(m_bRedraw)
{
GetClientRect(&m_ClientRect);
MemDC.CreateCompatibleDC(pDC);
CBrush brush;
brush.CreateSolidBrush(RGB(255,255,255));
pOldBrush=MemDC.SelectObject(&brush);
pOldPen=MemDC.SelectObject(&m_AxPen);
m_MemBitmap.CreateCompatibleBitmap(pDC,MaxWidth,MaxHight);
//当MaxWidth<=5200时
//执行正确,MaxWidth>=5200时执行不正确,控件变为空白)
pOldBitmap=MemDC.SelectObject(&m_MemBitmap);
MemDC.FillRect(CRect(0,0,MaxWidth,MaxHight),&brush);
DrawCoo(&MemDC,&m_ClientRect); //在MemDC上进行绘图
m_bRedraw=FALSE;
}
pDC->BitBlt(0,0,m_ClientRect.Width(),m_ClientRect.Height(),&MemDC,ScrollPosX*(MaxWidth/m_ClientRect.Width()),
(MaxHight-m_ClientRect.Height())/2+(ScrollPosY-m_ClientRect.Height()/2)*(MaxHight/m_ClientRect.Height())-20 ,SRCCOPY);
CFont *pold=pDC->SelectObject(&m_LegFont);
pDC->TextOut(25,6,"Y(单位: 0.0001mm)");
pDC->TextOut(25,24,"X(单位: 0.1mm)");
pDC->SelectObject(pold);
}
本绘图操作当MaxWidth<=5200时执行完全正确,MaxWidth>5200时执行不正确,控件变为空白,让我想不通,难道位图大小还有限定吗?(这里MaxHight>8000)请各位指教!
--------------------next---------------------
阅读(1734) | 评论(0) | 转发(0) |