ITChart Draw() Exceptions
Posted: Thu Apr 07, 2005 7:14 pm
I am calling the TChart Draw(DC, Left, Top, Right, Bottom: Integer) method and I see a range check error, sometimes. It is like I get 3 exceptions and then it draws properly. I saw a similar bug reported with printing, and wonder if this isn't a related issue.
Code: Select all
CRect rect = get_window_rect();
CDC *dc = parent->GetWindowDC();
CDC memdc;
memdc.CreateCompatibleDC(dc);
if(cached_bmp == 0 ||
(bmp_width != rect.Width() || bmp_height != rect.Height()))
{
if(cached_bmp)
{
cached_bmp->DeleteObject();
delete cached_bmp;
}
cached_bmp = new CBitmap;
bmp_width = rect.Width();
bmp_height = rect.Height();
cached_bmp->CreateCompatibleBitmap(dc,bmp_width,bmp_height);
}
CBitmap *old_bmp = memdc.SelectObject(cached_bmp);
try
{
Draw(reinterpret_cast<long>(memdc.m_hDC),0,0,rect.Width(),rect.Height());
}
catch(COleDispatchException *e)
{
if(cached_bmp)
{
cached_bmp->DeleteObject();
delete cached_bmp;
cached_bmp = 0;
}
e->Delete();
trace("TChart::draw() catch(COleDispatchException)");
}
catch(COleException *e)
{
if(cached_bmp)
{
cached_bmp->DeleteObject();
delete cached_bmp;
cached_bmp = 0;
}
e->Delete();
trace("TChart::draw() catch(COleException)");
}
memdc.SelectObject(old_bmp);
ReleaseDC(&memdc);
ReleaseDC(dc);