Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Updateproblem when scrolling picture

Status
Not open for further replies.

MagiMike

Technical User
Jun 5, 2003
44
SE
I'm blitting som lines onto a static text or picture control.
It works fine until I shrink the window so that the scrollbars appear.
If the window is smaller than the picture control I get gray areas instead of white in the right and bottom areas of the picture control.
Is this a known bug or am I doing something wrong? I've been trying to call OnPaint wherever I can but it doesn't solve the problem.


Drawing code (OnPaint)
CWnd* wnd = GetDlgItem(IDC_GRAFVIEWER);
CBitmap bmp;
CBitmap *oBmp=&bmp;

CRect rect, temp;
wnd->GetWindowRect(rect);
wnd->GetClientRect(temp);
ScreenToClient(rect);

CDC *pDC, mDC;
pDC = GetDC();
mDC.CreateCompatibleDC(pDC);
bmp.CreateCompatibleBitmap(pDC, temp.right, temp.bottom);
oBmp = mDC.SelectObject(&bmp);

mDC.FillRect(temp, &CBrush(0xFFFFFF));

p->DrawPic(mDC); // Consists of drawing some lines

pDC->BitBlt(rect.left, rect.top, rect.right , rect.bottom, &mDC, 0, 0, SRCCOPY);

mDC.SelectObject(oBmp);
wnd->RedrawWindow();
ReleaseDC(pDC);
ReleaseDC(&mDC);
 
Figured it out myself. The problem is with the call to BitBlt when the whole window is not showed.
Apparently if I try to blit something bigger than the destination window (when made smaller) a portion does not get blitted.
I have to do some calculations with the rects for source and destination.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top