Re: Can't copy the background of my simple control
In the post from yesterday, I told you that the bitmap you were selecting
into the Memory DC was not being created. That didn't mean that you should
get rid of the bitmap all togther.
See this code:
CPaintDC dc(this); // device context for painting
CWnd* pParent = GetParent();
CRect rect;
GetClientRect(&rect);
ClientToScreen(&rect);
pParent->ScreenToClient(&rect);
CDC *pDC = pParent->GetDC();
CDC memdc;
memdc.CreateCompatibleDC(pDC);
CBitmap Bmp;
Bmp.CreateCompatibleBitmap(pDC,rect.Width(),Rect.Height());
CBitmap *pOldBitmap = memdc.SelectObject(&Bmp);
memdc.BitBlt(0,0,rect.Width(),rect.Height(),pDC,rect.left,
rect.top,SRCCOPY);
dc.BitBlt (0,0,rect.Width(),rect.Height(), &memdc, 0,0, SRCCOPY);
memdc.SelectObject(pOldBitmap);
pParent->ReleaseDC(pDC);
But I am telling you that this will not work as you would think that it
would. Everytime you bitblt from the parent you might bitblt the controls
content at the same time!
AliR.
"Maik Wiege" <mswiege-nospan-@gmx.de> wrote in message
news:44569f63$0$22280$9b622d9e@news.freenet.de...
Hi!
I still didn't find any solution for my problem. I now simplified my
OnPaint like this:
CPaintDC dc(this); // device context for painting
CWnd* pParent = GetParent();
CRect rect;
GetClientRect(&rect);
ClientToScreen(&rect);
pParent->ScreenToClient(&rect);
CDC *pDC = pParent->GetDC();
CDC memdc;
memdc.CreateCompatibleDC(pDC);
memdc.BitBlt(0,0,rect.Width(),rect.Height(),pDC,rect.left,
rect.top,SRCCOPY);
dc.BitBlt (0,0,rect.Width(),rect.Height(), &memdc, 0,0, SRCCOPY);
pParent->ReleaseDC(pDC);
So I simply try to copy the parents area to memory and than copy it to
the controls dc, but in my program the area of the control is not drawn
at all.
What is wrong here? While debugging I found out that no function returns
an error and the pParent pointer points to the correct CChildView-object.
Help please! I'm stuck here now the whole day! :-(
Maik