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. showing graphics in view after closing dialog

showing graphics in view after closing dialog

Scheduled Pinned Locked Moved C / C++ / MFC
graphicsgame-devquestion
6 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
    coda_x
    wrote on last edited by
    #1

    I coded my drawing using OpenGl rendering in my SDI view ON_PAINT handler event but because i need to take in user inputs from a dialog, what should i do such that my graphics will only appear after i have entered variables into the dialog and close the dialog?

    V 1 Reply Last reply
    0
    • C coda_x

      I coded my drawing using OpenGl rendering in my SDI view ON_PAINT handler event but because i need to take in user inputs from a dialog, what should i do such that my graphics will only appear after i have entered variables into the dialog and close the dialog?

      V Offline
      V Offline
      vcplusplus
      wrote on last edited by
      #2

      Try putting your code in OnDraw() instead of OnPaint(); It will also make your life easier when you decide to print your drawing. Here is some code from the CView class. As you can see, OnPaint() and OnPrint() both call OnDraw(). I hope this helps. void CView::OnPaint() { // standard paint routine CPaintDC dc(this); OnPrepareDC(&dc); OnDraw(&dc); } void CView::OnPrint(CDC* pDC, CPrintInfo*) { ASSERT_VALID(pDC); // Override and set printing variables based on page number OnDraw(pDC); // Call Draw } void CView::OnDraw(CDC*) { }

      C 1 Reply Last reply
      0
      • V vcplusplus

        Try putting your code in OnDraw() instead of OnPaint(); It will also make your life easier when you decide to print your drawing. Here is some code from the CView class. As you can see, OnPaint() and OnPrint() both call OnDraw(). I hope this helps. void CView::OnPaint() { // standard paint routine CPaintDC dc(this); OnPrepareDC(&dc); OnDraw(&dc); } void CView::OnPrint(CDC* pDC, CPrintInfo*) { ASSERT_VALID(pDC); // Override and set printing variables based on page number OnDraw(pDC); // Call Draw } void CView::OnDraw(CDC*) { }

        C Offline
        C Offline
        coda_x
        wrote on last edited by
        #3

        okie but erm won't the SDI view also show the image right at the beginning? let's say i have dialog A which contains the length, breadth of a rect and based on this, i draw the rect in the Cview.....so actually what i did was code the drawing in my dialog OnOK() so that when i click the ok button after i input the dimensions, after the dialog closes, my drawing will then appear in view, but unfotunately, windows doesn't auotmatically redisplay my rect coz dialog was in front of view....then I transferred my drawing into CView on_paint so that now refreshing is automatically done but now i have a problem of showing the rect when only after i close the dialog. hmmm..

        V 1 Reply Last reply
        0
        • C coda_x

          okie but erm won't the SDI view also show the image right at the beginning? let's say i have dialog A which contains the length, breadth of a rect and based on this, i draw the rect in the Cview.....so actually what i did was code the drawing in my dialog OnOK() so that when i click the ok button after i input the dimensions, after the dialog closes, my drawing will then appear in view, but unfotunately, windows doesn't auotmatically redisplay my rect coz dialog was in front of view....then I transferred my drawing into CView on_paint so that now refreshing is automatically done but now i have a problem of showing the rect when only after i close the dialog. hmmm..

          V Offline
          V Offline
          vcplusplus
          wrote on last edited by
          #4

          After you close the dialog call InvalidateRect(); CMyDialog m; m.DoModal(); InvalidateRect(); // This will send WM_PAINT message

          C 1 Reply Last reply
          0
          • V vcplusplus

            After you close the dialog call InvalidateRect(); CMyDialog m; m.DoModal(); InvalidateRect(); // This will send WM_PAINT message

            C Offline
            C Offline
            coda_x
            wrote on last edited by
            #5

            i get an error for InvalidateRect():function does not take in zero parameters. Actually from my SDI,i have dialog A which has a child dialog B. It is only when dialog B is closed then i want to show the graphics in view.This is wat i did: void CDialogB :: OnOK() //to show graphics when { //dialog is closed CDialog::OnOK(); InvalidateRect(); } void CDialog:: OnDraw() { UpdateData(); float l=m_length; float b=m_breadth; ...... drawing code here ..... } void CView::OnPaint() { m_dialogB.OnDraw(); } is this the correct approach?

            V 1 Reply Last reply
            0
            • C coda_x

              i get an error for InvalidateRect():function does not take in zero parameters. Actually from my SDI,i have dialog A which has a child dialog B. It is only when dialog B is closed then i want to show the graphics in view.This is wat i did: void CDialogB :: OnOK() //to show graphics when { //dialog is closed CDialog::OnOK(); InvalidateRect(); } void CDialog:: OnDraw() { UpdateData(); float l=m_length; float b=m_breadth; ...... drawing code here ..... } void CView::OnPaint() { m_dialogB.OnDraw(); } is this the correct approach?

              V Offline
              V Offline
              vcplusplus
              wrote on last edited by
              #6

              Then add the necessary parameters to InvalidateRect(). You might want to check out the scribble section at this web site. I know it is a MDI application but it should still work with a SDI application. http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vctutor98/html/tutorhm.asp?frame=true You can find all this infomation on your MSDN Library disks that came with Visual C++ 6.0

              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