?
Solved

focus and z-order between dialogs and views

Posted on 1998-09-27
1
Medium Priority
?
526 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 400 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

Get proactive database performance tuning online

At Percona’s web store you can order full Percona Database Performance Audit in minutes. Find out the health of your database, and how to improve it. Pay online with a credit card. Improve your database performance now!

Question has a verified solution.

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

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…
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.
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

752 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