MFC sure can be confusing......... When would you use OnPaint() instead of OnDraw() for drawing in an MFC application? Should on be used in a dialog and the other used in a doc/view app?
ComboController
Posts
-
OnPaint() as opposed to OnDraw() -
Releasing hDC after rendering;)This is my OpenGL window OnPaint function: void COGLWnd::OnPaint() { CPaintDC dc(this); HDC hdc = ::GetDC(m_hWnd); if (!SetGLContext(hdc)) return; RenderScene(); SwapBuffers(hdc); ::ReleaseDC(m_hWnd, hdc) ; } 1. Do I need to release the hdc at the end of the function? 2. And would using the 'dc.m_hDC' of the CPaintDC class as the device context instead of the retrieved from ::GetHDC(m_hWmd) make any difference. Are they both the same thing?
-
OpenGL in a portion of a dialog boxThanks I'll give it a go. Is any special cleanup necessary if you use this approach?
-
OpenGL in a portion of a dialog boxI have created a dialog that is rendered into by an OpenGL RC. Now that I have that going I'd like to be able to add a few control variables. What I'd like to do is set OpenGL to only render into a portion of the dialog..... I was wondering how I'd go about this, do I have to create another window in the dialog? If so, what type is appropriate, I'm only getting started with MFC. A quick aside, in my OnPaint() I call the base OnPaint() function and THEN render my scene, yet the OK and CANCEL buttons still get painted. Shouldn't they be painted over by RC?
-
CMemoryStateI don't know what you mean by '#define new..." I'm overriding the MFCApp::ExitInstance() function and calling the base ExitInstance(). Then I do the object dump, so I can't see why a few objects are still allocated. BTW I am extremely paranoid about memory leaks after having lots of trouble with my last PC (crashing.......sloooowdown etc..)
-
CMemoryStateI know how to use the functions, I want to know where is the best place to call them in the App. I was calling the oldState.Checkpoint() in the App() and newState.Checkpoint() in App::ExitInstance() but it returned a difference. When I called oldState.Checkpoint() it listed (I think) a CDocTemplateManager object and a CSingleDoctemplate object....... So this is obviously not the best place to call oldState.DumpAllObjectsSince() to check overall memory usage. Is there a function after App::ExitInstance to do the difference check in?
-
CMemoryState;)Hi, newbie here, I was wondering what's the best way to use the CMemoryState object to check for memory leaks in a MFC program. I want to set a checkpoint at the very beginning of the program and the very end, so in what functions should I call oldState.Checkpoint() and newState.Checkpoint()?