Solved

nested Dialogs

Posted on 1998-01-26
4
404 Views
Last Modified: 2013-11-20
I need a full example to handle nested Dialogs.

The Dialog has a List box control. Depending on the List box selection a child dialog should be displayed.
0
Comment
Question by:Gus012498
  • 3
4 Comments
 

Accepted Solution

by:
petern012698 earned 100 total points
ID: 1314850
Gus,
I can knock-up a sample for you, how many types of dialogs would you like.  Is it context-sensitive from the list box or is the same dialog for each one.  Do you want the dialog to be shown on double-click.
Send me an eMail and I will create it for you overnight.

0
 
LVL 1

Author Comment

by:Gus012498
ID: 1314851
The program is a little bit more complex.

I have a main application which loads several DLL. Each DLL register a Document Template or a Connection Template.

The Dialog is used to setup the Connections.
The Listbox contains the names of the Templates.

When a listbox item is selected and the Create Button is pressed a new Connection is created an a part of the main Dialog should display the Connectionsparameters. (Portnumber and Baudrate for RS232, Device ID for CAN, ...).

If your example shows me how to display one nested dialog, i should be able to do the rest.
0
 

Expert Comment

by:petern012698
ID: 1314852
Gus,
Unfortunatly not all of your answer was visible, can you email me at peter.nunn@purist.com with the details, so I can get onto it
0
 

Expert Comment

by:petern012698
ID: 1314853
Gus, I think I understood but you havn't responded to my eMail.  Here are 2 cpp files that implement an outer dialog with a list-box (CTemplateDlg) and a nested dialog (CConfigurationDlg) when a valid list-box item is selected the outer dialog is shown.
I can send the whole sample by eMail when you send it
--------------------------------------
#if !defined(AFX_TEMPLATEDLG_H__E8B62956_9626_11D1_9C84_004005325433__INCLUDED_)
#define AFX_TEMPLATEDLG_H__E8B62956_9626_11D1_9C84_004005325433__INCLUDED_

#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000
// TemplateDlg.h : header file
//

/////////////////////////////////////////////////////////////////////////////
// CTemplateDlg dialog

class CTemplateDlg : public CDialog
{
// Construction
public:
      CTemplateDlg(CWnd* pParent = NULL);   // standard constructor

// Dialog Data
      //{{AFX_DATA(CTemplateDlg)
      enum { IDD = IDD_TEMPLATES };
      CListBox      m_wndTemplateName;
      CString      m_strTemplateName;
      //}}AFX_DATA


// Overrides
      // ClassWizard generated virtual function overrides
      //{{AFX_VIRTUAL(CTemplateDlg)
      protected:
      virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
      //}}AFX_VIRTUAL

// Implementation
protected:

      // Generated message map functions
      //{{AFX_MSG(CTemplateDlg)
      afx_msg void OnConfiguration();
      virtual BOOL OnInitDialog();
      //}}AFX_MSG
      DECLARE_MESSAGE_MAP()
};

//{{AFX_INSERT_LOCATION}}
// Microsoft Developer Studio will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_TEMPLATEDLG_H__E8B62956_9626_11D1_9C84_004005325433__INCLUDED_)
---------------------------------------
// TemplateDlg.cpp : implementation file
//

#include "stdafx.h"
#include "Nested.h"
#include "TemplateDlg.h"

#include "configurationdlg.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CTemplateDlg dialog


CTemplateDlg::CTemplateDlg(CWnd* pParent /*=NULL*/)
      : CDialog(CTemplateDlg::IDD, pParent)
{
      //{{AFX_DATA_INIT(CTemplateDlg)
      m_strTemplateName = _T("");
      //}}AFX_DATA_INIT
}


void CTemplateDlg::DoDataExchange(CDataExchange* pDX)
{
      CDialog::DoDataExchange(pDX);
      //{{AFX_DATA_MAP(CTemplateDlg)
      DDX_Control(pDX, IDC_TEMPLATE_NAME, m_wndTemplateName);
      DDX_LBString(pDX, IDC_TEMPLATE_NAME, m_strTemplateName);
      //}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CTemplateDlg, CDialog)
      //{{AFX_MSG_MAP(CTemplateDlg)
      ON_BN_CLICKED(IDC_CONFIGURATION, OnConfiguration)
      //}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CTemplateDlg message handlers

void CTemplateDlg::OnConfiguration()
      {
      // TODO: Add your control notification handler code here
      if(m_wndTemplateName.GetCurSel() == LB_ERR)
            {
            AfxMessageBox(_T("Please select a template name"));
            return;
            }

      CConfigurationDlg dlg;

      // this reads the contents of the variables
      UpdateData();

      // copy it accross
      dlg.m_strTemplateName = m_strTemplateName;
      dlg.DoModal();
      }

BOOL CTemplateDlg::OnInitDialog()
{
      CDialog::OnInitDialog();
      
      // TODO: Add extra initialization here

      // we add some dummy names here
      m_wndTemplateName.AddString(_T("Template 1"));
      m_wndTemplateName.AddString(_T("Template 2"));
      m_wndTemplateName.AddString(_T("Template 3"));
      m_wndTemplateName.AddString(_T("Template 4"));
      m_wndTemplateName.AddString(_T("Template 5"));
      m_wndTemplateName.AddString(_T("Template 6"));
      m_wndTemplateName.AddString(_T("Template 7"));
      m_wndTemplateName.AddString(_T("Template 8"));
      
      return TRUE;  // return TRUE unless you set the focus to a control
                    // EXCEPTION: OCX Property Pages should return FALSE
}
------------------------------
#if !defined(AFX_CONFIGURATIONDLG_H__E8B62957_9626_11D1_9C84_004005325433__INCLUDED_)
#define AFX_CONFIGURATIONDLG_H__E8B62957_9626_11D1_9C84_004005325433__INCLUDED_

#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000
// ConfigurationDlg.h : header file
//

/////////////////////////////////////////////////////////////////////////////
// CConfigurationDlg dialog

class CConfigurationDlg : public CDialog
{
// Construction
public:
      CConfigurationDlg(CWnd* pParent = NULL);   // standard constructor

// Dialog Data
      //{{AFX_DATA(CConfigurationDlg)
      enum { IDD = IDD_CONFIGURATION };
      BOOL      m_bParam1;
      CString      m_strTemplateName;
      //}}AFX_DATA


// Overrides
      // ClassWizard generated virtual function overrides
      //{{AFX_VIRTUAL(CConfigurationDlg)
      protected:
      virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
      //}}AFX_VIRTUAL

// Implementation
protected:

      // Generated message map functions
      //{{AFX_MSG(CConfigurationDlg)
      virtual BOOL OnInitDialog();
      //}}AFX_MSG
      DECLARE_MESSAGE_MAP()
};

//{{AFX_INSERT_LOCATION}}
// Microsoft Developer Studio will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_CONFIGURATIONDLG_H__E8B62957_9626_11D1_9C84_004005325433__INCLUDED_)
------------------------------------------
// ConfigurationDlg.cpp : implementation file
//

#include "stdafx.h"
#include "Nested.h"
#include "ConfigurationDlg.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CConfigurationDlg dialog


CConfigurationDlg::CConfigurationDlg(CWnd* pParent /*=NULL*/)
      : CDialog(CConfigurationDlg::IDD, pParent)
{
      //{{AFX_DATA_INIT(CConfigurationDlg)
      m_bParam1 = FALSE;
      m_strTemplateName = _T("");
      //}}AFX_DATA_INIT
}


void CConfigurationDlg::DoDataExchange(CDataExchange* pDX)
{
      CDialog::DoDataExchange(pDX);
      //{{AFX_DATA_MAP(CConfigurationDlg)
      DDX_Check(pDX, IDC_PARAM1, m_bParam1);
      DDX_Text(pDX, IDC_TEMPLATE_NAME, m_strTemplateName);
      //}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CConfigurationDlg, CDialog)
      //{{AFX_MSG_MAP(CConfigurationDlg)
      //}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CConfigurationDlg message handlers

BOOL CConfigurationDlg::OnInitDialog()
{
      CDialog::OnInitDialog();
      
      // TODO: Add extra initialization here

      // rather simple demo of changing the param
      m_bParam1 = m_strTemplateName == _T("Template 2");

      // this sets the controls from the parameters
      UpdateData(FALSE);
      
      return TRUE;  // return TRUE unless you set the focus to a control
                    // EXCEPTION: OCX Property Pages should return FALSE
}
-----------------------------------
Hope it helps
0

Featured Post

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Expand to include initial dialog with two choices. 9 78
countEvens challenge 2 105
Message not shown 5 52
Increment column based of a FK 8 23
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…
Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
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 video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

832 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