IShowFrame中有一个方法,在用MFC写的进程内组件中是这样写的:ShowFrame(/*in*/RECT* p_rectShow,/*in*/HINSTANCE hInstance,/*out*/HWND* p_hwndChild,/*in*/ULONG pWnd)
{
CWnd* cp_wndParent = reinterpret_cast<CWnd*>(pWnd);

AfxSetResourceHandle(AfxGetApp()->m_hInstance);
pThis->m_wndRight.Create(IDD_DIALOG_HEXVIEW,cp_wndParent)//IDD_DIALOG_HEXVIEW为一个空的对话框资源
pThis->m_wndRight.ShowWidnow(SW_SHOW);
AfxSetResourceHandle(hInstance);
}
这段代码在debug模式下会触发断言:"cp_wndParent指向的不是一个有效对象?"(ASSERT_VALID(cp_WndParent));
ASSERT_VALID在msdn中的解释为:"Specifies an object of a class derived from CObject that has an overriding version of the AssertValid member function."我在客户端调用这个借口方法时用这个宏判断了一下输入参数没有问题,可是为什么到了组件里就有问题?到底什么才是一个有效的对象?我使用release编译后没有问题,但是好像会引起bug?如果要在组件中创建子窗口到底该怎么做!大家讨论讨论,MFC的内部结构太变态了!