I have an app which i draw a PNG on the button and all works great until i want to redraw the whole screen.
when i try to redraw the whole screen it gives me an exception and points to this part of afxwin2.h
_AFXWIN_INLINE CDC* CWnd::GetDC()
{ ASSERT(::IsWindow(m_hWnd)); return CDC::FromHandle(::GetDC(m_hWnd)); }
here's my code:
void CODBIIMakerDatabaseDlg::DrawBackground(CDC *dc/*=0*/)
{
Gdiplus::Image * BG;//GDI+ Background variable
if(!dc)
dc = GetDC();
Gdiplus::Graphics grpx(*dc);//GDI Graphics container
Gdiplus::Rect rect(0,0,473,261);//GDI image pos and size
BG = Gdiplus::Image::FromFile(L"Image\\BackGround.png",FALSE);
grpx.DrawImage(BG,rect);
}
It works great the first time DrawBackground is called but when i call DrawBackground with this
DrawBackground(0);
I get an exception when the if(!dc) is executed.
Am i Calling GetDC() wrong?