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