Re: trying to get active view pointer from cmainframe
MDIGetActive()
i checked the code API internally
checking mdiclient is not null
then it is using sendmessage function to get the handle of active child
window
then it uses CWnd::FromHandle()
CMDIChildWnd* pWnd = (CMDIChildWnd*)CWnd::FromHandle(hWnd);
ASSERT(pWnd == NULL ||
pWnd->IsKindOf(RUNTIME_CLASS(CMDIChildWnd)));//and //here it asserts
why here it is asserting.
if it is getting handle to the child window then what is the problem?
//for convenience here is code of MDIGetActive
CMDIChildWnd* CMDIFrameWnd::MDIGetActive(BOOL* pbMaximized) const
{
// check first for MDI client window not created
if (m_hWndMDIClient == NULL)
{
if (pbMaximized != NULL)
*pbMaximized = FALSE;
return NULL;
}
// MDI client has been created, get active MDI child
HWND hWnd = (HWND)::SendMessage(m_hWndMDIClient, WM_MDIGETACTIVE, 0,
(LPARAM)pbMaximized);
CMDIChildWnd* pWnd = (CMDIChildWnd*)CWnd::FromHandle(hWnd);
ASSERT(pWnd == NULL || pWnd->IsKindOf(RUNTIME_CLASS(CMDIChildWnd)));
// check for special pseudo-inactive state
if (pWnd != NULL && pWnd->m_bPseudoInactive &&
(pWnd->GetStyle() & WS_VISIBLE) == 0)
{
// Window is hidden, active, but m_bPseudoInactive -- return NULL
pWnd = NULL;
// Ignore maximized flag if pseudo-inactive and maximized
if (pbMaximized != NULL)
*pbMaximized = FALSE;
}
return pWnd;
}
when i debugged this code it shows me that hwnd of child is not null
means it is getting child window's handle so why it is asserting
Thanks & regards
Harshal shete