Solved

Child Window Z-Order problem..

Posted on 1998-11-13
6
1,000 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 1

Expert Comment

by:V245
Comment Utility
I think the solution is to override WM_WINDOWPOSCHANGING:

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

Author Comment

by:Gumpster
Comment Utility
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
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

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…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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.
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

772 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

12 Experts available now in Live!

Get 1:1 Help Now