Hello,

I have a question. I work in visual c++ in a document/view arhitecture (SDI application) and i draw some stuff with some opengl functions (cubes, cylinders) but when i hit the "New" menu from the File menu it doesn't erase or clear my drawing :( I don't know why. Can you help me how to ovewrite eventually this : OnFileNew function, and where should i put it? In the CView class or in CMainFrame?
What should i write in it to erase my background after i draw something and to provide a clear canvas ?

Thank you in advance for your help.

Recommended Answers

All 5 Replies

Have you used glClear()?

Yes, i tried it, and it doesn't work, i don't know why.
I thought Visual C++ does this by itself like for the Exit function from the File menu, but it seems i have to overwrite it.
I tried to write in OnFileNew : GetParent()->PostMessage(WM_ERASEBKGND) in order to post the erase background message but still no improvement.

Well, that's all I know... sorry.

when i hit the "New" menu from the File menu it doesn't erase or clear my drawing I don't know why.

A bit difficult to answer because not knowing how your drawing code is setup, so I guess that the drawing code is within the view class/file i.e. the document class is unrelated to the drawing procedure(?). Now when you hit the File/New, MFC calls your document's OnNewDocument() handler, which returns TRUE and the drawing code continues uninterrupted/unchanged.

You might add code to the OnNewDocument(), which tells the view's drawing code to do something else (i.e. blank out the view) in case it detects that the File/New has been invoked. E.g. add a BOOL member variable to the doc class and check e.g. in view's OnDraw() handler whether to draw or not.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.