Re: Application crashes on BitBlt after a while.. need help please
"vorange" <orangepic@yahoo.com> ha scritto nel messaggio
news:e5046e63-1541-4b7d-adbe-4fd964573170@26g2000hsk.googlegroups.com...
The debugger says it crashes on the statement BitBlt.
Apparently it is unable to get a handle to something (i think the DC)
when using BitBlt and fails an ASSERT.
[...]
void ScanDialog::OnPaint()
{
CPaintDC dc(this);
CDC dcMemory;
bool falsetrue = dcMemory.CreateCompatibleDC (&dc);
if(falsetrue == TRUE)
{
DrawCompass(IDC_AZIMUTH, &dcMemory);
}
}
Just for test, try using CMemDC class:
http://www.codeproject.com/KB/GDI/flickerfree.aspx
void ScanDialog::OnPaint()
{
CPaintDC dc(this);
DrawCompass( IDC_AZIMUTH, &dc );
}
void ScanDialog::DrawCompass( int id, CDC * dc )
{
CMemDC dcMemory( dc );
... use dcMemory
}
The ASSERT on BitBlt DC seems strange to me, because you are doing a control
yourself here (if (dc2 != NULL ...):
dc2 = pWndd->GetDC(); // dc is a CDC *dc2
if(dc2 != NULL)
{
pWndd->GetClientRect(&rect); // rect is a CRect
nX = rect.left;
nY = rect.top;
if(dc2->BitBlt(nX, nY, bmpInfo.bmWidth, bmpInfo.bmHeight,
dcMemory, 0, 0, SRCCOPY) != 0)
Giovanni