Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Will WM_SIZE repaint whole client area????

Will WM_SIZE repaint whole client area????

Scheduled Pinned Locked Moved C / C++ / MFC
question
18 Posts 3 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C CodeMak

    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

    N Offline
    N Offline
    Nishad S
    wrote on last edited by
    #9

    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 -

    C 1 Reply Last reply
    0
    • C CodeMak

      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.....:)

      N Offline
      N Offline
      Nishad S
      wrote on last edited by
      #10

      Please see[^]

      - NS -

      1 Reply Last reply
      0
      • B Bhavesh Bagadiya

        Code is doing exactly what it should do.. what do you want to do buddy ?? :confused:

        C Offline
        C Offline
        CodeMak
        wrote on last edited by
        #11

        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

        1 Reply Last reply
        0
        • N Nishad S

          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 -

          C Offline
          C Offline
          CodeMak
          wrote on last edited by
          #12

          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.

          B N 2 Replies Last reply
          0
          • C CodeMak

            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.

            B Offline
            B Offline
            Bhavesh Bagadiya
            wrote on last edited by
            #13

            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.

            1 Reply Last reply
            0
            • C CodeMak

              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.

              N Offline
              N Offline
              Nishad S
              wrote on last edited by
              #14

              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 -

              C 1 Reply Last reply
              0
              • N Nishad S

                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 -

                C Offline
                C Offline
                CodeMak
                wrote on last edited by
                #15

                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??

                B 1 Reply Last reply
                0
                • C CodeMak

                  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??

                  B Offline
                  B Offline
                  Bhavesh Bagadiya
                  wrote on last edited by
                  #16

                  i don't understand which previous content u r seeing ?? all is new after resize of window.

                  C 1 Reply Last reply
                  0
                  • B Bhavesh Bagadiya

                    i don't understand which previous content u r seeing ?? all is new after resize of window.

                    C Offline
                    C Offline
                    CodeMak
                    wrote on last edited by
                    #17

                    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.

                    N 1 Reply Last reply
                    0
                    • C CodeMak

                      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.

                      N Offline
                      N Offline
                      Nishad S
                      wrote on last edited by
                      #18

                      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 -

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • World
                      • Users
                      • Groups