showing graphics in view after closing dialog
-
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?
-
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?
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*) { }
-
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*) { }
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..
-
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..
After you close the dialog call InvalidateRect(); CMyDialog m; m.DoModal(); InvalidateRect(); // This will send WM_PAINT message
-
After you close the dialog call InvalidateRect(); CMyDialog m; m.DoModal(); InvalidateRect(); // This will send WM_PAINT message
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?
-
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?
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