Solved

nested Dialogs

Posted on 1998-01-26
4
387 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

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…
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
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 gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

743 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

17 Experts available now in Live!

Get 1:1 Help Now