Solved

nested Dialogs

Posted on 1998-01-26
4
411 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
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.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

830 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