Will WM_SIZE repaint whole client area????
-
arshadkc wrote:
the previous content remains at that position
I think you are not erasing the background. Can you show me the code in OnPaint and OnEraseBkgnd?
arshadkc wrote:
i min/max or send a wm_paint to dialog box the previous content gets disappeared
It is expected, right?
- NS -
this is what i do.....in paint CRect rect(10,10,200,200); this->GetClientRect(&rect); CPaintDC dc(this); dc.FillRect(&rect,new CBrush(RGB(255,0,255))); dc.Rectangle(rect.Width()/2,rect.Height()/2,100,100); i dnt process WM_SIZE or WM_ERASEBKGND ya thats what i expect.....:)
-
Thank u all for replyin this is what i do.....in paint CRect rect(10,10,200,200); this->GetClientRect(&rect); CPaintDC dc(this); dc.FillRect(&rect,new CBrush(RGB(255,0,255))); dc.Rectangle(rect.Width()/2,rect.Height()/2,100,100); i dnt process WM_SIZE or WM_ERASEBKGND if WM_SIZE repaints whole client area, why is it not filling the rect coz of which the previous content is displayed... am i correct?? Thanx'n'advnance
Code is doing exactly what it should do.. what do you want to do buddy ?? :confused:
-
Thank u all for replyin this is what i do.....in paint CRect rect(10,10,200,200); this->GetClientRect(&rect); CPaintDC dc(this); dc.FillRect(&rect,new CBrush(RGB(255,0,255))); dc.Rectangle(rect.Width()/2,rect.Height()/2,100,100); i dnt process WM_SIZE or WM_ERASEBKGND if WM_SIZE repaints whole client area, why is it not filling the rect coz of which the previous content is displayed... am i correct?? Thanx'n'advnance
The problem is what I said before. Dialog will not have CS_VREDRAW or CS_HREDRAW styles. So you have to call Invalidate( FALSE ) in the OnSize(). It will solve the issue. Please note:
arshadkc wrote:
dc.FillRect(&rect,new CBrush(RGB(255,0,255)));
This is wrong. The objects will not be deleted. You can use FillSolidRect for simple fills.
- NS -
-
this is what i do.....in paint CRect rect(10,10,200,200); this->GetClientRect(&rect); CPaintDC dc(this); dc.FillRect(&rect,new CBrush(RGB(255,0,255))); dc.Rectangle(rect.Width()/2,rect.Height()/2,100,100); i dnt process WM_SIZE or WM_ERASEBKGND ya thats what i expect.....:)
-
Code is doing exactly what it should do.. what do you want to do buddy ?? :confused:
ok :) I want to display a rectangle at the middle of dialog box. for that i . first fills my whole client area with a particular color . then i draw a rectangle at the middle of ma client area. . Now when i maximize my window i get two rectangle's. one at top left and other at middle. . so i just want to know why am i gettin the top left rectangle when i maximize. Hope u got it... may be i am wrong , if wrong please help me... Thanx'n'advance
-
The problem is what I said before. Dialog will not have CS_VREDRAW or CS_HREDRAW styles. So you have to call Invalidate( FALSE ) in the OnSize(). It will solve the issue. Please note:
arshadkc wrote:
dc.FillRect(&rect,new CBrush(RGB(255,0,255)));
This is wrong. The objects will not be deleted. You can use FillSolidRect for simple fills.
- NS -
-
ya i have done it. its working fine. thank u but what my doubt is if its not calling OnPaint then how whole client area is filled (ie dc.FillRect(&rect,new CBrush(RGB(255,0,255))??? and thanx for FillSolidRect.
it getting filled because u have given entire client area as parameter "&rect" which u had retried with GetClientRect() and then you r drawing a rectangle with default WHITE brush so it drawn as white box. WM_SIZE always repaints entire window. if u want only middle rectangle to filled use dc.SelectObject(new Brush) function and then dc.Rectangle() function which will draw rectangle with selected brush.
-
ya i have done it. its working fine. thank u but what my doubt is if its not calling OnPaint then how whole client area is filled (ie dc.FillRect(&rect,new CBrush(RGB(255,0,255))??? and thanx for FillSolidRect.
It is true that the window is not painted while resizing. But it will be painted in all other scenarios. That is at the time of creation, when some window moves over it, etc. Hope you got the idea. And I found that your code for drawing a rectangle in the centre of the window is not fine. You may have to update it as, CPaintDC dc( this ); CRect rect; GetClientRect( &rect ); dc.FillSolidRect( &rect, RGB( 255, 0, 255 )); const int nWidth = 100; const int nHeight = 100; int nX1 = ( rect.Width() - nWidth ) / 2; int nY1 = ( rect.Height() - nHeight ) / 2; dc.Rectangle( nX1, nY1, nX1 + nWidth, nY1 + nHeight );
- NS -
-
It is true that the window is not painted while resizing. But it will be painted in all other scenarios. That is at the time of creation, when some window moves over it, etc. Hope you got the idea. And I found that your code for drawing a rectangle in the centre of the window is not fine. You may have to update it as, CPaintDC dc( this ); CRect rect; GetClientRect( &rect ); dc.FillSolidRect( &rect, RGB( 255, 0, 255 )); const int nWidth = 100; const int nHeight = 100; int nX1 = ( rect.Width() - nWidth ) / 2; int nY1 = ( rect.Height() - nHeight ) / 2; dc.Rectangle( nX1, nY1, nX1 + nWidth, nY1 + nHeight );
- NS -
Actually i am just trying out some Device context functions. i just want to place a rectangle somewhere middle. anyways thanx for placing it exactly. But stil i didnt get whats happening. I feel that a call is made to OnPaint after OnSize thats why its painting whole client area. According to me after i paint my whole client area i should not see any previous content. But here its not happening like that.?? Can anyone clear my doubt??
-
Actually i am just trying out some Device context functions. i just want to place a rectangle somewhere middle. anyways thanx for placing it exactly. But stil i didnt get whats happening. I feel that a call is made to OnPaint after OnSize thats why its painting whole client area. According to me after i paint my whole client area i should not see any previous content. But here its not happening like that.?? Can anyone clear my doubt??
i don't understand which previous content u r seeing ?? all is new after resize of window.
-
i don't understand which previous content u r seeing ?? all is new after resize of window.
ya exactly thats what i want , everything should be new... this is what happening . I display a rect(i ll name it "rectA") at center of dialog. . when i maximize the dialog. i get two rectangle's. One is my previous one (ie "rectA") at the top left and the other one is at the center. . what i expect is only one rectangle at center. i dont want "rectA" to be displayed again when i maximize because everything should be cleared.
-
ya exactly thats what i want , everything should be new... this is what happening . I display a rect(i ll name it "rectA") at center of dialog. . when i maximize the dialog. i get two rectangle's. One is my previous one (ie "rectA") at the top left and the other one is at the center. . what i expect is only one rectangle at center. i dont want "rectA" to be displayed again when i maximize because everything should be cleared.
That is because entire area is not re-painted. As I mentioned earlier, if the window class does not have the styles (CS_HREDRAW and CS_VREDRAW), the painting will not occur when the window is resized. That's the problem happened to you. For a dialog window, these styles will not be there. So you have to call Invalidate() from the OnSize.
- NS -