Discussion:
colored rectangle and scrolling form
(too old to reply)
Z.K.
2006-06-22 15:31:54 UTC
Permalink
I have a project that when the form appears on the screen I have to scroll
to the right to see the entire form. This is fine, but I also have a
rectangle I draw from one edge of the form to the other. When I scroll to
the right it does not draw the rectangle all the way, but if I resize the
form it does. How do I get the rectangle to redraw when I scroll to the
right and also how do I get the form to appear its full size when the
application starts. My OnDraw code is below:

Z.K.
void CT45662BLView::OnDraw(CDC* pDC)

{

// TODO: Add your specialized code here and/or call the base class

//declare rectangle to hold window rectangle info

CRect WinRect;

//get window rectangle

::GetWindowRect(this->m_hWnd,&WinRect);

//store window rectangle width value

int width = WinRect.Width();

//create a solid color brush

CBrush aBrush(RGB(0,0,255));

//assign brush for drawing

pDC->SelectObject(&aBrush);

//draw rectangle

pDC->FillSolidRect(0,0,width,75,RGB(0,0,255));


}
Scott McPhillips [MVP]
2006-06-22 16:44:02 UTC
Permalink
Post by Z.K.
I have a project that when the form appears on the screen I have to scroll
to the right to see the entire form. This is fine, but I also have a
rectangle I draw from one edge of the form to the other. When I scroll to
the right it does not draw the rectangle all the way, but if I resize the
form it does. How do I get the rectangle to redraw when I scroll to the
right and also how do I get the form to appear its full size when the
The form is bigger than the window: That's why it needs scrolling.
Since you are using the window width to draw your rectangle, you're not
drawing it as wide as the form.

Assuming that you are using CFormView, you can get the total form size
by calling GetTotalSize. In this class the (0,0) coordinate is the top
left corner of the form, not the currently visible portion.
--
Scott McPhillips [VC++ MVP]
Z.K.
2006-06-22 17:49:27 UTC
Permalink
Post by Scott McPhillips [MVP]
Post by Z.K.
I have a project that when the form appears on the screen I have to scroll
to the right to see the entire form. This is fine, but I also have a
rectangle I draw from one edge of the form to the other. When I scroll to
the right it does not draw the rectangle all the way, but if I resize the
form it does. How do I get the rectangle to redraw when I scroll to the
right and also how do I get the form to appear its full size when the
The form is bigger than the window: That's why it needs scrolling.
Since you are using the window width to draw your rectangle, you're not
drawing it as wide as the form.
Assuming that you are using CFormView, you can get the total form size
by calling GetTotalSize. In this class the (0,0) coordinate is the top
left corner of the form, not the currently visible portion.
--
Scott McPhillips [VC++ MVP]
No, the left portion is visible, but the far right portion is not and when I
scroll to the right, that part of the rectangle is missing. I will try the
GetTotalSize though. Thanks.

Z.K.
Z.K.
2006-06-22 17:58:08 UTC
Permalink
Post by Scott McPhillips [MVP]
Post by Z.K.
I have a project that when the form appears on the screen I have to scroll
to the right to see the entire form. This is fine, but I also have a
rectangle I draw from one edge of the form to the other. When I scroll to
the right it does not draw the rectangle all the way, but if I resize the
form it does. How do I get the rectangle to redraw when I scroll to the
right and also how do I get the form to appear its full size when the
The form is bigger than the window: That's why it needs scrolling.
Since you are using the window width to draw your rectangle, you're not
drawing it as wide as the form.
Assuming that you are using CFormView, you can get the total form size
by calling GetTotalSize. In this class the (0,0) coordinate is the top
left corner of the form, not the currently visible portion.
--
Scott McPhillips [VC++ MVP]
Ok, that worked nicely. Thanks a lot.

Z.K.

Loading...