Solved

Child Window Z-Order problem..

Posted on 1998-11-13
6
1,032 Views
Last Modified: 2013-11-20
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?
0
Comment
Question by:Gumpster
  • 3
  • 2
6 Comments
 
LVL 1

Accepted Solution

by:
elf_k earned 150 total points
ID: 1324629
It seems to me
wndChild.SetWindowPos(&wndChildInsertAfter<îr &wndTop or &wndBottom>,0,0,0,0,SWP_NOSIZE | SWP_NOMOVE);
will help. If not, please describe more details of the problem.
0
 

Author Comment

by:Gumpster
ID: 1324630
The toplevel window will contain a series of child windows; each child window will contain some graphics on its own separate layer(like adobe photoshop).  Each window will have to be fixed in the z-order chain, even when the window is clicked apon and activated.  I want to be able to move/size each child window without bringing that window to the front.
0
 
LVL 1

Expert Comment

by:elf_k
ID: 1324631
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.
0
VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

 
LVL 1

Expert Comment

by:V245
ID: 1324632
I think the solution is to override WM_WINDOWPOSCHANGING:

void CChildFrame::OnWindowPosChanging(WINDOWPOS* lpWinPos)
{
      lpWinPos->flags |= SWP_NOZORDER;
}
0
 

Author Comment

by:Gumpster
ID: 1324633
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::OnWindowPosChanged(WINDOWPOS FAR* lpwndpos)
{
      CWnd::OnWindowPosChanged(lpwndpos);
      
      if (m_pInsertAfter!=NULL)
            this->SetWindowPos(m_pInsertAfter, 0,0,0,0, SWP_NOSIZE|SWP_NOMOVE);
}

0
 

Author Comment

by:Gumpster
ID: 1324634
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::OnWindowPosChanged(WINDOWPOS FAR* lpwndpos)
{
      CWnd::OnWindowPosChanged(lpwndpos);
      
      if (m_pInsertAfter!=NULL)
            this->SetWindowPos(m_pInsertAfter, 0,0,0,0, SWP_NOSIZE|SWP_NOMOVE);
}

0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question