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. On paint calling order

On paint calling order

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestion
5 Posts 4 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.
  • K Offline
    K Offline
    Kharfax
    wrote on last edited by
    #1

    Hi I have a picture box in my dialog, but I need to write something on top of it. The problem is that the onPaint dialog method is getting called before the control repaints itself, so I can never see the text. Someone knows what can I do to avoid this, and be able to write on top of the picture box? Thanks in advance

    N P K M 4 Replies Last reply
    0
    • K Kharfax

      Hi I have a picture box in my dialog, but I need to write something on top of it. The problem is that the onPaint dialog method is getting called before the control repaints itself, so I can never see the text. Someone knows what can I do to avoid this, and be able to write on top of the picture box? Thanks in advance

      N Offline
      N Offline
      Newbie00
      wrote on last edited by
      #2

      Use picture box onPaint method instead of dialog onPaint method. I think, it's called event, not method.

      1 Reply Last reply
      0
      • K Kharfax

        Hi I have a picture box in my dialog, but I need to write something on top of it. The problem is that the onPaint dialog method is getting called before the control repaints itself, so I can never see the text. Someone knows what can I do to avoid this, and be able to write on top of the picture box? Thanks in advance

        P Offline
        P Offline
        PJ Arends
        wrote on last edited by
        #3

        At the end of the dialog's OnPaint method post a custom message to the dialog. In that custom message handler paint your text.

        void CMyDialog::OnPaint()
        {
        ...
        CDialog::OnPaint()

        PostMessage(WM\_APP + 1, 0, 0);
        

        }

        LRESULT CMyDialog::OnWmAppPlusOne(WPARAM, LPARAM)
        {
        ClientDC dc(this);
        dc.TextOut(...);
        }

        Now all the usual painting is done first, then you custom message gets processed to draw the text on top of all the other controls.


        You may be right
        I may be crazy
        -- Billy Joel --

        Within you lies the power for good, use it!!!

        1 Reply Last reply
        0
        • K Kharfax

          Hi I have a picture box in my dialog, but I need to write something on top of it. The problem is that the onPaint dialog method is getting called before the control repaints itself, so I can never see the text. Someone knows what can I do to avoid this, and be able to write on top of the picture box? Thanks in advance

          K Offline
          K Offline
          Kharfax
          wrote on last edited by
          #4

          Thanks for the quick reply people :D

          1 Reply Last reply
          0
          • K Kharfax

            Hi I have a picture box in my dialog, but I need to write something on top of it. The problem is that the onPaint dialog method is getting called before the control repaints itself, so I can never see the text. Someone knows what can I do to avoid this, and be able to write on top of the picture box? Thanks in advance

            M Offline
            M Offline
            Michael Dunn
            wrote on last edited by
            #5

            Add the WS_CLIPCHILDREN style to the dialog, so the dialog's window proc won't paint over its child controls.

            --Mike-- Visual C++ MVP :cool: LINKS~! Ericahist | PimpFish | CP SearchBar v3.0 | C++ Forum FAQ Ford, what's this fish doing in my ear?

            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