Solved

nested Dialogs

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Excel Use VBA to get user's Mac Address for their computer 5 109
WinWaitActive parameters 12 31
method notes when mouse over in eclipse 5 82
Change to event 1 100
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 …
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.
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

911 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

20 Experts available now in Live!

Get 1:1 Help Now