Gumpster
asked on
Child Window Z-Order problem..
I have a CWnd top-level window and several CWnd derived child windows inside it.
How do I fix the Z-order of these child windows, even when the windows is clicked apon?
How do I fix the Z-order of these child windows, even when the windows is clicked apon?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Aha! When you want to avoid changing windows Z-Order you can catch WM_WINDOWPOSCHANGING message and "or" flags field of WINDOWPOS struct with SWP_NOZORDER. Your window will not change ZOrder in this case.
I think the solution is to override WM_WINDOWPOSCHANGING:
void CChildFrame::OnWindowPosCh anging(WIN DOWPOS* lpWinPos)
{
lpWinPos->flags |= SWP_NOZORDER;
}
void CChildFrame::OnWindowPosCh
{
lpWinPos->flags |= SWP_NOZORDER;
}
ASKER
I tried this and it did not work. This is because you can call SetWindowPos with the SWP_NOSENDCHANGING flag and no WM_WINDOWPOSCHANGING message is sent.
Instead I have trapped the WM_WINDOWPOSCHANGED message and added a SetWindowPos call there:
void CChildWindow::OnWindowPosC hanged(WIN DOWPOS FAR* lpwndpos)
{
CWnd::OnWindowPosChanged(l pwndpos);
if (m_pInsertAfter!=NULL)
this->SetWindowPos(m_pInse rtAfter, 0,0,0,0, SWP_NOSIZE|SWP_NOMOVE);
}
Instead I have trapped the WM_WINDOWPOSCHANGED message and added a SetWindowPos call there:
void CChildWindow::OnWindowPosC
{
CWnd::OnWindowPosChanged(l
if (m_pInsertAfter!=NULL)
this->SetWindowPos(m_pInse
}
ASKER
I tried this and it did not work. This is because you can call SetWindowPos with the SWP_NOSENDCHANGING flag and no WM_WINDOWPOSCHANGING message is sent.
Instead I have trapped the WM_WINDOWPOSCHANGED message and added a SetWindowPos call there:
void CChildWindow::OnWindowPosC hanged(WIN DOWPOS FAR* lpwndpos)
{
CWnd::OnWindowPosChanged(l pwndpos);
if (m_pInsertAfter!=NULL)
this->SetWindowPos(m_pInse rtAfter, 0,0,0,0, SWP_NOSIZE|SWP_NOMOVE);
}
Instead I have trapped the WM_WINDOWPOSCHANGED message and added a SetWindowPos call there:
void CChildWindow::OnWindowPosC
{
CWnd::OnWindowPosChanged(l
if (m_pInsertAfter!=NULL)
this->SetWindowPos(m_pInse
}
ASKER