Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

focus and z-order between dialogs and views

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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

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.
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.
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Suggested Courses

636 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