Solved

Child Window Z-Order problem..

Posted on 1998-11-13
6
1,024 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Decoding 32 bit binary streams 6 37
how do i create updater to My Activex application? 3 79
sum13 challenge 24 90
ShiftLeft challenge 21 76
Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
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.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

895 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now