Solved

focus and z-order between dialogs and views

Posted on 1998-09-27
1
524 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

Technology Partners: 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

Suggested Solutions

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 …
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
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.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

726 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