On 13 May 2005 17:47:52 -0700, "Leo" wrote:

>
>I have a main window and a child which is a modeless dialog (it also
>has a COM wrapper). The child can response to the OnClose event of the
>main window. However, when the child response to the main to destroy
>itself, I got assertion error.


I found that IsWindow has a problem in at least some versions of
Windows CE: it hangs if the argument has the value
INVALID_HANDLE_VALUE. So I have a wrapper that checks the argument
before calling IsWindow.

Sorry, but I can't help with your real problem.


>
>Any idea? Thanks.
>
>This is my code:
> if (m_pChildWin && ::IsWindow(m_pChildWin->m_hWnd))
> m_pChildWin->DestroyWindow();
>
>It fails at here:
>OOL CWnd:estroyWindow()
>{
>...
> pWnd = (CWnd*)pMap->LookupPermanent(m_hWnd); // Can't find it
>athough m_hWnd is valid
>#ifdef _DEBUG
> hWndOrig = m_hWnd;
>#endif
>#ifdef _AFX_NO_OCC_SUPPORT
>...
>#else //_AFX_NO_OCC_SUPPORT
> if ((m_hWnd != NULL) || (m_pCtrlSite != NULL))
> {
> if (m_pCtrlSite == NULL)
> bResult = :estroyWindow(m_hWnd); // m_hWnd changed to 0 here
> ...
>}
>#endif //_AFX_NO_OCC_SUPPORT
>
> if (hWndOrig!= NULL)
> if (pWnd != NULL)
> {...
> }
> else
> {
>#ifdef _DEBUG
> ASSERT(m_hWnd == hWndOrig); // Crashing here
>#endif


-----------------------------------------
To reply to me, remove the underscores (_) from my email address (and please indicate which newsgroup and message).

Robert E. Zaret, eMVP
PenFact, Inc.
500 Harrison Ave., Suite 3R
Boston, MA 02118
www.penfact.com