程序虽说正常运行,但是安装BoundsChecker后他说ReleaseDC()有泄漏,请大家帮我看看吧。打 * 号的那句话是必须那样写的,因为调用的其他Dll中的函数。谢谢
void CPokerWnd::OnPaint()
{
//TRACE("\nCPokerWnd::OnPaint() called!\n");
CPaintDC dc(this); // device context for painting
CString sOut;
char buffer[200];
if(bIsJoker)
{
CBitmap bitmap;
CDC dcMemory;
bitmap.LoadBitmap (/*IDB_BITMAP1*/iBitmapID);
dcMemory.CreateCompatibleDC (&dc);
dcMemory.SelectObject (&bitmap);
dc.BitBlt (0,0,300,409,&dcMemory,0,0,SRCCOPY);//APPENDED BY ZYY
//摘自《vc技术内幕》p221
//书上在OnDraw()里面写,此处我写到OnPaint()里面
dc.SetBkMode (TRANSPARENT);
dc.SetTextColor (RGB(255,0,0));
sOut="Joker";
dc.TextOut (3,50,sOut);
dc.TextOut(3,3,buffer,wsprintf(buffer,"card:%d",iCard));
dc.TextOut(3,30,buffer,wsprintf(buffer,"type:%d",iType));
}
else
{
// Do not call CWnd::OnPaint() for painting messages
//int type = 1;//ectFACES;
//
// Draw a card!!
//
HDC hdc;
CDC *pdc;
//iCard=68;
//iType=2;//test information
//hdc=::GetDC (m_hWnd );
pdc=GetDC();
hdc=pdc->m_hDC ; cdtDraw(hdc, 0, 0, iCard/*iValueFaceFirst*/, iType, 0);//————(*) //::ReleaseDC (m_hWnd ,hdc);
ReleaseDC(pdc); dc.SetBkMode (TRANSPARENT);
dc.SetTextColor (RGB(0,0,255));
//dc.TextOut(3,3,buffer,wsprintf(buffer,"f:%d,s:%d",iFace,iSuit));
//dc.TextOut(3,30,buffer,wsprintf(buffer,"type:%d",iType));
}
}
void CPokerWnd::OnPaint()
{
//TRACE("\nCPokerWnd::OnPaint() called!\n");
CPaintDC dc(this); // device context for painting
CString sOut;
char buffer[200];
if(bIsJoker)
{
CBitmap bitmap;
CDC dcMemory;
bitmap.LoadBitmap (/*IDB_BITMAP1*/iBitmapID);
dcMemory.CreateCompatibleDC (&dc);
dcMemory.SelectObject (&bitmap);
dc.BitBlt (0,0,300,409,&dcMemory,0,0,SRCCOPY);//APPENDED BY ZYY
//摘自《vc技术内幕》p221
//书上在OnDraw()里面写,此处我写到OnPaint()里面
dc.SetBkMode (TRANSPARENT);
dc.SetTextColor (RGB(255,0,0));
sOut="Joker";
dc.TextOut (3,50,sOut);
dc.TextOut(3,3,buffer,wsprintf(buffer,"card:%d",iCard));
dc.TextOut(3,30,buffer,wsprintf(buffer,"type:%d",iType));
}
else
{
// Do not call CWnd::OnPaint() for painting messages
//int type = 1;//ectFACES;
//
// Draw a card!!
//
HDC hdc;
CDC *pdc;
//iCard=68;
//iType=2;//test information
//hdc=::GetDC (m_hWnd );
pdc=GetDC();
hdc=pdc->m_hDC ; cdtDraw(hdc, 0, 0, iCard/*iValueFaceFirst*/, iType, 0);//————(*) //::ReleaseDC (m_hWnd ,hdc);
ReleaseDC(pdc); dc.SetBkMode (TRANSPARENT);
dc.SetTextColor (RGB(0,0,255));
//dc.TextOut(3,3,buffer,wsprintf(buffer,"f:%d,s:%d",iFace,iSuit));
//dc.TextOut(3,30,buffer,wsprintf(buffer,"type:%d",iType));
}
}
解决方案 »
- CStringW 类型的字符串,如何判断里边的某个字符是全角(汉字)还是半角(英文和数字)
- 一个小程序,需要FTP功能,谁能给我提供一个Ftp Client的源码.
- 同一个对话框内控件间的制约问题!不是你想象的那种。。。
- strlen()函数这样用错在那儿?
- 请教关于VC中按钮怎么实现 正常状态,按下状态,获得输入状态,
- 怎样实现程序只能运行一次?
- vc前辈门请留下QQ联系,多多指教,.我的QQ是155314330
- 《深入浅出MFC》下载
- 在vc6.0中用boost中的正则表达式的regex_match怎么在一段文字中找一特定格式的句子.
- --------(绝)------------------AAA----------------------------(密)-----------
- 怎么才能得到查询到纪录的个数???数据库是ACCEss
- 问一下窗体最小化的问题,急
用完了要dcMemory.DeleteDC();
bitmap.DeleteObject()
pdc=GetDC();
hdc=pdc->m_hDC
把GetDC()那一句去掉,相应的releaseDC也去掉,而上面的第二句改为hdc=dc.m_hDC
这样就行了。