Solved

focus and z-order between dialogs and views

Posted on 1998-09-27
1
525 Views
Last Modified: 2013-11-20
I am developing an MDI MFC application. For each view there might be several modeless dialogs open. Well, I also have some problems:
1. How do I keep the dialogs "under" the MainFrame's frame (in the client's area?) ?
2. When activating a view, I want it to get the focus and move "on top" of ALL other windows in the MainFrame's client area, including the dialogs.
3. Since each dialog is connected to a certain view, can I also bring all the associated dialogs to the front, when I activate their "owner" view?
0
Comment
Question by:dagan
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 1

Accepted Solution

by:
VAM345 earned 200 total points
ID: 1322647
I think to you can do this:

Client`s area window is m_hWndMDIClient of CMDIFrameWnd.

To set dialog (modeless dialog)in Client`s area of CMDIFrameWnd you do this:
1. Dialog style has Child in ypu template and has no border.
2. In Create of CMDIFrameWnd do this:
BOOL CMyMDIFrameWnd::Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, CCreateContext* pContext)
{
      if (CMDIFrameWnd::Create(lpszClassName, lpszWindowName, dwStyle, rect, pParentWnd, lpszMenuName, dwExStyle, pContext)) == NULL)
            return FALSE;

      m_pMyDialog1 = new CMyDialog1(m_hWndMDIClient);
      if(m_pMyDialog1->Create() == NULL)
            return FALSE;

      CRect rcClient;
      m_pMyDialog1->GetClientRect(rcClient);
      m_pMyDialog1->MoveWindow(0,0,rcClient.right,rcClient.bottom);
      m_pMyDialog1->ShowWindow(SW_SHOW);
      
      m_pMyDialog1 = new CMyDialog1(m_hWndMDIClient);
      if(m_pMyDialog1->Create() == NULL)
            return FALSE;

      m_pMyDialog2 = new CMyDialog2(m_hWndMDIClient);
      if(m_pMyDialog2->Create() == NULL)
            return FALSE;

      CRect rcClient;
      m_pMyDialog2->GetClientRect(rcClient);
      m_pMyDialog2->MoveWindow(0,100,rcClient.right,rcClient.bottom);
      m_pMyDialog2->ShowWindow(SW_SHOW);

      return TRUE;
}

To add dialog in view do as in CMDIFrameWnd

BOOL CMyView::Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, CCreateContext* pContext)
{
      if (CView::Create(lpszClassName, lpszWindowName, dwStyle, rect, pParentWnd, nID, pContext) == NULL)
            return FALSE;

      m_pMyDialog1 = new CMyDialog1(this);
      if(m_pMyDialog1->Create() == NULL)
            return FALSE;

      CRect rcClient;
      m_pMyDialog1->GetClientRect(rcClient);
      m_pMyDialog1->MoveWindow(0,0,rcClient.right,rcClient.bottom);
      m_pMyDialog1->ShowWindow(SW_SHOW);
      
      m_pMyDialog1 = new CMyDialog1(m_hWndMDIClient);
      if(m_pMyDialog1->Create() == NULL)
            return FALSE;

      m_pMyDialog2 = new CMyDialog2(m_hWndMDIClient);
      if(m_pMyDialog2->Create() == NULL)
            return FALSE;

      CRect rcClient;
      m_pMyDialog2->GetClientRect(rcClient);
      m_pMyDialog2->MoveWindow(0,0,rcClient.right,rcClient.bottom);
      m_pMyDialog2->ShowWindow(SW_SHOW);

      return TRUE;
}



0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
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.
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…

717 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