CDESKTOP class starts ~

xiaoxiao2021-03-06  39

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_pwinlist; whenever a new window handle, press him to the front of the List container. (push_front). m_pwinlist.push_front (pnewwin); first specify the order of form processing. In general, the painting form is in accordance with the top of the form, in the last window of the upper layer, to cover the lower window. It is therefore defined as follows: 1. The first window is in the front end of the List container (Front, Begin ()) 2. Processing the painting function starts a form drawn from the backend of the List container .// Painting All Windows Bool CDesktop :: DRAW IdirectDrawSurface * LPDDS, LPRECT LPRECT) {IF (m_pwinlist.empty ()) Return False;

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.

转载请注明原文地址:https://www.9cbs.com/read-55570.html

New Post(0)