Home > Software engineering > MFC application documents, I the pointer variable defined in a window, and then zero it in another w
MFC application documents, I the pointer variable defined in a window, and then zero it in another w
Time:10-10
MFC application documents, I the pointer variable defined in a window, and then zero it in another window, can see to zero, but why the debugger running back to the current window, how the value of the pointer variable is back? I create multiple views form, program is running, can switch between each form to deal with reality, but I am currently a form in close and then open the form, the program runs is failed, then check the handle to the child form has changed, wanted to remove child form a pointer to the variable to create a handle, but the value is a NULL pointer variable, is back, please masters teach you!
CodePudding user response:
Not come back, but run shows different window instance is different, so the pointer is a value, so before shows that the new window, you need to determine whether a window handle to effective, Multiple document USES the following way, visit different View:
POSITION pos=GetFirstViewPosition (); While (pos!=NULL) { PView=GetNextView (pos); if(! PView - & gt; IsKindOf (pClass)) break;
For example, when access to the main frame adopts a method:
1, what you call in another window to clean up the 0, may not be the current window variable pointer; 2, memory disorders, check the structure and the members of the class alignment of bytes to variables.