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. need advice on drawing code!

need advice on drawing code!

Scheduled Pinned Locked Moved C / C++ / MFC
graphicsc++game-devhelpquestion
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.
  • C Offline
    C Offline
    coda_x
    wrote on last edited by
    #1

    i know that normally i should code my drawing for eg a rectangle in SDI view.cpp. But my project(SDI) consists of several dialogs requiring user input for rect dimensions. so is it advisable to code in the view.cpp and with my member dialog variables declared there, or i can code my drawing in the respesctive dialogs.cpp and then point to SDI view? i tried the former and i get assertion error coz when the program was 1st run, it tried to draw the rect which should not be the case as i want the user to open the dialog within the SDI and input the dimensions then when "OK" is clicked only will the rectangle appear...can anyone advise? btw, i was using opengl to draw my rect.

    L 1 Reply Last reply
    0
    • C coda_x

      i know that normally i should code my drawing for eg a rectangle in SDI view.cpp. But my project(SDI) consists of several dialogs requiring user input for rect dimensions. so is it advisable to code in the view.cpp and with my member dialog variables declared there, or i can code my drawing in the respesctive dialogs.cpp and then point to SDI view? i tried the former and i get assertion error coz when the program was 1st run, it tried to draw the rect which should not be the case as i want the user to open the dialog within the SDI and input the dimensions then when "OK" is clicked only will the rectangle appear...can anyone advise? btw, i was using opengl to draw my rect.

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      Generally speaking, proper architecture would suggest that code that draws in the view should be in the view class. If you want to prevent drawing until after soliciting user input, use a boolean or some other check to ensure that the drawing code doesn't execute until you're ready.

      C 1 Reply Last reply
      0
      • L Lost User

        Generally speaking, proper architecture would suggest that code that draws in the view should be in the view class. If you want to prevent drawing until after soliciting user input, use a boolean or some other check to ensure that the drawing code doesn't execute until you're ready.

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

        hmm,I am now trying to code my ONPAINT fuction in a dialog.cpp while keeping all the other ONCreate, OnDestroy, On Setpixeldescription in my view. How do I call a pointer to the view.cpp from my dialog ONPAINT? Is it feasible?

        L 1 Reply Last reply
        0
        • C coda_x

          hmm,I am now trying to code my ONPAINT fuction in a dialog.cpp while keeping all the other ONCreate, OnDestroy, On Setpixeldescription in my view. How do I call a pointer to the view.cpp from my dialog ONPAINT? Is it feasible?

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          If you need a pointer to the view, just create a member variable of that type in the dialog class, and initialize it after creating, but before showing, the dialog. For instance, in the dialog header, you'd have something like CMyView* m_ptrOwnerView; In the function that creates the dialog, CMyDialog md; md.m_ptrOwnerView = this; md.ShowModal(); However, if you're trying to draw into the view in response to the WM_PAINT message received by the dialog, you have a bit of a problem. You need to draw in response to the WM_PAINT received by the view, not that recieved by the dialog. The WM_PAINT messages sent to the dialog by the OS are not related to view. Re-think your architecture.

          C 1 Reply Last reply
          0
          • L Lost User

            If you need a pointer to the view, just create a member variable of that type in the dialog class, and initialize it after creating, but before showing, the dialog. For instance, in the dialog header, you'd have something like CMyView* m_ptrOwnerView; In the function that creates the dialog, CMyDialog md; md.m_ptrOwnerView = this; md.ShowModal(); However, if you're trying to draw into the view in response to the WM_PAINT message received by the dialog, you have a bit of a problem. You need to draw in response to the WM_PAINT received by the view, not that recieved by the dialog. The WM_PAINT messages sent to the dialog by the OS are not related to view. Re-think your architecture.

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

            erm, okie i a bit confused over this WM_PAINT thing, so what u are saying is that, if i code my draw rect in my dialog's WM_PAINT function and then i point it to my CView, the CView will not be able to show the rect on screen is it? i been trying to find out the best way to show my grpahics on SDI window whenever user input dimensions into my dialog...so i know i have a problem linking this dialog to my view.then the best way is to code all my drawing into the CView WM_PAINT function?

            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