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. I want to draw on a control,but the Dialog app will draw it automatic!

I want to draw on a control,but the Dialog app will draw it automatic!

Scheduled Pinned Locked Moved C / C++ / MFC
questionhelp
5 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.
  • W Offline
    W Offline
    white jungle
    wrote on last edited by
    #1

    In a DLG based app,I want to draw something on a CONTROL (static) and there are some another CONTROL on the Dialog. I Get the DC of the Static control and draw something on it,but failed.I see nothing on the static control.So I delete the sentnce CDialog::OnPaint() And then,all of these control except the staitc can't be seen.(they are not being paint) I want to paint the Static control but hope the other control will draw it themself! How can I do? Thank you for your help! Don't look at me in that way!

    T 1 Reply Last reply
    0
    • W white jungle

      In a DLG based app,I want to draw something on a CONTROL (static) and there are some another CONTROL on the Dialog. I Get the DC of the Static control and draw something on it,but failed.I see nothing on the static control.So I delete the sentnce CDialog::OnPaint() And then,all of these control except the staitc can't be seen.(they are not being paint) I want to paint the Static control but hope the other control will draw it themself! How can I do? Thank you for your help! Don't look at me in that way!

      T Offline
      T Offline
      Ted Ferenc
      wrote on last edited by
      #2

      from the MSDN under GetDlgItem, changed to be a CStatic, assuming you are using the MFC // uses GetDlgItem to return a pointer to a user interface control CStatic* pStatic; pStatic= (CStatic*) GetDlgItem(IDC_STATIC1); pStatic->SetWindowText(_T("Hello world"));


      If I have seen further it is by standing on the shoulders of Giants. - Isaac Newton 1676

      W 1 Reply Last reply
      0
      • T Ted Ferenc

        from the MSDN under GetDlgItem, changed to be a CStatic, assuming you are using the MFC // uses GetDlgItem to return a pointer to a user interface control CStatic* pStatic; pStatic= (CStatic*) GetDlgItem(IDC_STATIC1); pStatic->SetWindowText(_T("Hello world"));


        If I have seen further it is by standing on the shoulders of Giants. - Isaac Newton 1676

        W Offline
        W Offline
        white jungle
        wrote on last edited by
        #3

        I just want to draw a picture on it! exmaple: I want to draw some lines on the static control! when I do this ,nothing can be seen in the control. Don't look at me in that way!

        T 1 Reply Last reply
        0
        • W white jungle

          I just want to draw a picture on it! exmaple: I want to draw some lines on the static control! when I do this ,nothing can be seen in the control. Don't look at me in that way!

          T Offline
          T Offline
          Ted Ferenc
          wrote on last edited by
          #4

          I am working from memory here. In that case the best method, I think, would be to subclass the control. Or you could try get the CDC of the static control, using my #1 method and use this to paint, also add the paint logic into the OnPaint. BUT the control may decide to paint it it's slef therefore overwriting what you have put there! I use this method to place a bitmap into a static control.


          If I have seen further it is by standing on the shoulders of Giants. - Isaac Newton 1676

          W 1 Reply Last reply
          0
          • T Ted Ferenc

            I am working from memory here. In that case the best method, I think, would be to subclass the control. Or you could try get the CDC of the static control, using my #1 method and use this to paint, also add the paint logic into the OnPaint. BUT the control may decide to paint it it's slef therefore overwriting what you have put there! I use this method to place a bitmap into a static control.


            If I have seen further it is by standing on the shoulders of Giants. - Isaac Newton 1676

            W Offline
            W Offline
            white jungle
            wrote on last edited by
            #5

            Thank you! I got it! Don't look at me in that way!

            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