Home > Software engineering > IsWindow to determine whether a window handle effectively and has destroyed the window still returns
IsWindow to determine whether a window handle effectively and has destroyed the window still returns
Time:09-26
MFC much document window CList deposit of a pointer to a window is open the window, the window is closed when not delete the window from CList pointer In another parts of the project need to traverse the Clist do some other operating The code below For (int I=0; Pos & amp; & i <(UINT) theApp. M_List. GetCount (); I++) { PView=theApp. M_List. GetNext (pos); If (pView & amp; & : : IsWindow (pView - & gt; M_hWnd)) { pView - & gt; Fun (); .//here occasionally cause wild pointer operations }
In sporadic cases, after the window is closed, the traversal code above IsWindow () and not return FALSE lead to the code above red part will cause the wild pointer manipulation,
What a great god help explain the reason,
CodePudding user response:
Can't you see all the code Roughly speculate that The CView is a wrapper for the window, its m_hwnd can also in, but the CView was released
CodePudding user response:
Window of the corresponding window in the Clist pointer when you need to buy to 0
CodePudding user response:
You traverse the View, should go through the document template CDocTemplate to traverse