Destruction of frame, documentation and view (VC learning notes)

xiaoxiao2021-03-06  180

1. Destruction of multi-view programs without documents and solutions

In a non-document multi-view program, the program main framework, subframe, and view, in general, if you close the program main framework, the program directly calls DestroyWindow, sub-frames, and views, but the program will not call DESTROYWINDOW and PostncDestroy two functions, if you close the view, the order is closed, the program first calls DESTROYWINDOW of the subframe, then calls the view's postncdestroy, then the POSTNCDESTROY of the sub-frame, there is no call to the view DESTROYWINDOW.

In some cases, it is necessary to ensure that the programs are closed. At this time, the order will result in a process. As mentioned earlier, only one DESTROYWINDOW function is called when the main frame is directly closed, and the rest of the functions are not executed. Solved ideas, we have to change the destruction of the program, before the destruction of the sub-frame is before the main frame is destroyed:

Cchildframe * pchildframe = (cchildframe *) this-> getActiveFrame ();

While (PChildframe)

{

PCHildFrame-> destroyWindow ();

PCHildFrame = (cchildframe *) THIS-> getActiveFrame ();

}

With this loop, all sub-frames can be deleted, in the loop, the calling getActiveFrame function is to get the current active subframe, when deleting the current active subframe, other sub-frames turn into an active subframe, so this method Will not cause death cycles.

2, the destruction order of multi-document view programs

It is similar to the above situation, just a document, its destruction is before the subframe of DESTROYWINDOW.

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

New Post(0)