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. NcPaint and Invalid rect/region

NcPaint and Invalid rect/region

Scheduled Pinned Locked Moved C / C++ / MFC
3 Posts 2 Posters 0 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 Offline
    C Offline
    Cepre We ye ko
    wrote on last edited by
    #1

    Just in few words my question is next: Is there a way to get current invalid region when CWnd gets WM_NCPAINT message (in OnNcPaint() handler)? Details: I have a main frame with few child dialogs placed on it. Dialogs have custom controls. Custom controls have specific non-client area and that area is drawn when the control gets WM_NCPAINT message. Now I want to invalidate (redraw) only a small part of my main frame calling InvalidateRgn(&invalidRgn). If that invalid area overlaps with control's non-client area - WM_NCPAINT is sent to the control. Code in control's OnNcPaint() is like this:

    void CMyCtrl::OnNcPaint()
    {
    CWindowDC dc(this);
    // dc.SelectClipRgn(&invalidRgn) ???
    DoPaint(&dc);
    ...
    }

    And it paints over all window dc of the control. Whole non-client area is repainted, not only invalid region which I've passed when called InvalidateRgn(&invalidRgn). That is a behaviour I want to get rid of. I need only invalid region to be repainted. My suggestion is that I need somehow to get current invalid region and select it before painting like

    dc.SelectClipRgn(&invalidRgn)

    So the question is can I do that? and if yes - how?

    L 1 Reply Last reply
    0
    • C Cepre We ye ko

      Just in few words my question is next: Is there a way to get current invalid region when CWnd gets WM_NCPAINT message (in OnNcPaint() handler)? Details: I have a main frame with few child dialogs placed on it. Dialogs have custom controls. Custom controls have specific non-client area and that area is drawn when the control gets WM_NCPAINT message. Now I want to invalidate (redraw) only a small part of my main frame calling InvalidateRgn(&invalidRgn). If that invalid area overlaps with control's non-client area - WM_NCPAINT is sent to the control. Code in control's OnNcPaint() is like this:

      void CMyCtrl::OnNcPaint()
      {
      CWindowDC dc(this);
      // dc.SelectClipRgn(&invalidRgn) ???
      DoPaint(&dc);
      ...
      }

      And it paints over all window dc of the control. Whole non-client area is repainted, not only invalid region which I've passed when called InvalidateRgn(&invalidRgn). That is a behaviour I want to get rid of. I need only invalid region to be repainted. My suggestion is that I need somehow to get current invalid region and select it before painting like

      dc.SelectClipRgn(&invalidRgn)

      So the question is can I do that? and if yes - how?

      L Offline
      L Offline
      leon de boer
      wrote on last edited by
      #2

      GetUpdateRect API call retrieves the smallest bounding rectangle that encloses the update region and does the same function as BeginPaint which is only for use in WM_PAINT calls. Which answers your question ... My suggestion is that I need somehow to get current invalid region? ... and yes you can set it as a clip for your drawing if you want.

      In vino veritas

      C 1 Reply Last reply
      0
      • L leon de boer

        GetUpdateRect API call retrieves the smallest bounding rectangle that encloses the update region and does the same function as BeginPaint which is only for use in WM_PAINT calls. Which answers your question ... My suggestion is that I need somehow to get current invalid region? ... and yes you can set it as a clip for your drawing if you want.

        In vino veritas

        C Offline
        C Offline
        Cepre We ye ko
        wrote on last edited by
        #3

        GetUpdateRect returns only client area coordinates that should be updated. I need whole control's invalid area including non-client parts. Actually seems I've already find an answer: when Windows send WM_NCPAINT message it puts invalid region handle into wParam, but seems in coordinates relative to the desktop, - that's what I was looking for.

        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