Solved

focus and z-order between dialogs and views

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

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

Title # Comments Views Activity
ORA-01403: no data found 43 82
has77  challenge 9 67
java ^ examples 8 57
Window placement 17 65
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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 demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

706 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

18 Experts available now in Live!

Get 1:1 Help Now