CDESKTOP class is responsible for processing the window. When a window CreateWin, then add some Control on the Window, it is finished. Of course, you can keep its pointer for easy control, you can also use the FindWindow () function of the CDESKTOP class to find the name of the NAME, and return its pointer to its operation. When you draw a desktop window, just pass the desktop variable to the CGRAPH's renderDesktop () function, you can draw all the windows and their sub-controls. It's really convenient. It is inevitable that you must be intoxicated first. In CDESKTOP, I used STL, standard template library. #include using namespace std; uses the LIST container to save the window handle passed by the Add function. List
M_PWINITERATOR = m_pwinlist.end (); do {// Traversing all ephemes, executing DRAW M_PWINITERATOR -; (* m_pwiniterator) -> DRAW (LPDDS, LPRECT);} while (m_pwiniterator! = m_pinlist.begin ()); Return true;} 3. The processing message function starts tested one by one from the front end of the List container. Because the code initialized the form is taken separately, pay attention to a question: When switching the full screen / window mode, it will release the old DirectDraw. The SURFACE established by the old DirectDraw will also be invalid. Therefore, Desktop also executes the release function to release all the sub-forms before switching mode, and then reinitialize the form after reinitializing DirectDraw. Otherwise, the Surface pointer to the form will not be a valid DirectDrawSurface that will not be a valid DirectDrawSurface. This question spent almost an hour to go to Debug. Thanks to the remote debugging, two machines and use the code to see the code while debugging, otherwise, switching into full screen, you can't see the problem is troubled. By the way, it also removed the possible access before it was mentioned. It turns out that CSURFACE did not initialize LPDDS to NULL, so that the release macro could not determine the validity of the pointer, and directly executed an invalid release () operation. This is a low-level mistake, Sigh. Ok, continue to improve.