我在更新状态栏的函数中添加以下代码:
CDC* pDC = m_wndStatusBar.GetDC();
RECT m_PaneRect;
CPoint m_PanePoint;
//GetItemRect函数用来获得状态栏的位置信息
m_wndStatusBar.GetItemRect(1, (LPRECT)&m_PaneRect);
m_PanePoint.x=m_PaneRect.left+2;
m_PanePoint.y=m_PaneRect.top;
CDC dc;
dc.CreateCompatibleDC(pDC);
pOldUp=dc.SelectObject(&bmpUp);
bmpUp.GetBitmap(&bmUp);
pDC->BitBlt(m_PanePoint.x,m_PanePoint.y,m_PaneRect.right-m_PaneRect.left,m_PaneRect.bottom-m_PaneRect.top,&dc,0,0,SRCAND);
pDC->SetBkMode(TRANSPARENT);
pDC->SelectObject(pOldUp);
pDC->DeleteDC();
在程序运行中经常会出现如在WinHand.cpp中的199行出错,请问下是什么原因呀?
据我所知错误还可能会导致程序中的全局变量值改变,希望哪位大哥,大姐能帮个忙!
CDC* pDC = m_wndStatusBar.GetDC();
RECT m_PaneRect;
CPoint m_PanePoint;
//GetItemRect函数用来获得状态栏的位置信息
m_wndStatusBar.GetItemRect(1, (LPRECT)&m_PaneRect);
m_PanePoint.x=m_PaneRect.left+2;
m_PanePoint.y=m_PaneRect.top;
CDC dc;
dc.CreateCompatibleDC(pDC);
pOldUp=dc.SelectObject(&bmpUp);
bmpUp.GetBitmap(&bmUp);
pDC->BitBlt(m_PanePoint.x,m_PanePoint.y,m_PaneRect.right-m_PaneRect.left,m_PaneRect.bottom-m_PaneRect.top,&dc,0,0,SRCAND);
pDC->SetBkMode(TRANSPARENT);
pDC->SelectObject(pOldUp);
pDC->DeleteDC();
在程序运行中经常会出现如在WinHand.cpp中的199行出错,请问下是什么原因呀?
据我所知错误还可能会导致程序中的全局变量值改变,希望哪位大哥,大姐能帮个忙!
改成
pDC->ReleaseDC();
试试。
可能是调用了空指针。
到是我搞不懂,为什么用pDC->DeleteDC();会影响到其它的全局变量呢?能否解释一下?