Click here to Skip to main content
16,011,475 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: MFC dialog member sharing? (code included) Pin
Christophocles4-Mar-04 5:44
sussChristophocles4-Mar-04 5:44 
GeneralRe: MFC dialog member sharing? (code included) Pin
monrobot134-Mar-04 5:39
monrobot134-Mar-04 5:39 
GeneralRe: MFC dialog member sharing? (code included) Pin
Christophocles4-Mar-04 5:49
sussChristophocles4-Mar-04 5:49 
GeneralRe: MFC dialog member sharing? (code included) Pin
BlackDice4-Mar-04 6:07
BlackDice4-Mar-04 6:07 
GeneralRe: MFC dialog member sharing? (code included) Pin
Christophocles4-Mar-04 7:06
sussChristophocles4-Mar-04 7:06 
GeneralRe: MFC dialog member sharing? (code included) Pin
BlackDice4-Mar-04 8:23
BlackDice4-Mar-04 8:23 
GeneralRe: MFC dialog member sharing? (code included) Pin
Christophocles4-Mar-04 9:14
sussChristophocles4-Mar-04 9:14 
GeneralRe: MFC dialog member sharing? (code included) Pin
BlackDice4-Mar-04 9:30
BlackDice4-Mar-04 9:30 
I don't mind at all-- I just recently got access to the internet, and before I was WISHING I had anybody to ask about anything. Before I didn't have anyone to ask, because I taught myself and nobody else where I was knew anything about C++

here is the actual files:(Replace my CDlgtestDlg with your CDlg1)

this is two header files and two .cpp files (still willing to help if this doesn't do it) Cool | :cool:
********************************************************************
// dlgtestDlg.h : header file
//

#if !defined(AFX_DLGTESTDLG_H__B42E61F1_E754_4EAD_B51A_EF1DC2AE9DA8__INCLUDED_)
#define AFX_DLGTESTDLG_H__B42E61F1_E754_4EAD_B51A_EF1DC2AE9DA8__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

/////////////////////////////////////////////////////////////////////////////
// CDlgtestDlg dialog


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

// Dialog Data
//{{AFX_DATA(CDlgtestDlg)
enum { IDD = IDD_DLGTEST_DIALOG };
// NOTE: the ClassWizard will add data members here
//}}AFX_DATA

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

// Implementation
protected:
HICON m_hIcon;

// Generated message map functions
//{{AFX_MSG(CDlgtestDlg)
virtual BOOL OnInitDialog();
afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
afx_msg void OnPaint();
afx_msg HCURSOR OnQueryDragIcon();
afx_msg void OnButton1();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};

//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_DLGTESTDLG_H__B42E61F1_E754_4EAD_B51A_EF1DC2AE9DA8__INCLUDED_)

**************************************************************
// dlgtestDlg.cpp : implementation file
//

#include "stdafx.h"
#include "dlgtest.h"
#include "dlgtestDlg.h"
#include "dlg2.h"

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

/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About

class CAboutDlg : public CDialog
{
public:
CAboutDlg();

// Dialog Data
//{{AFX_DATA(CAboutDlg)
enum { IDD = IDD_ABOUTBOX };
//}}AFX_DATA

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

// Implementation
protected:
//{{AFX_MSG(CAboutDlg)
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};

CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
//{{AFX_DATA_INIT(CAboutDlg)
//}}AFX_DATA_INIT
}

void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CAboutDlg)
//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
//{{AFX_MSG_MAP(CAboutDlg)
// No message handlers
//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CDlgtestDlg dialog

CDlgtestDlg::CDlgtestDlg(CWnd* pParent /*=NULL*/)
: CDialog(CDlgtestDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CDlgtestDlg)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}



void CDlgtestDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CDlgtestDlg)
// NOTE: the ClassWizard will add DDX and DDV calls here
//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CDlgtestDlg, CDialog)
//{{AFX_MSG_MAP(CDlgtestDlg)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CDlgtestDlg message handlers

BOOL CDlgtestDlg::OnInitDialog()
{
CDialog::OnInitDialog();

// Add "About..." menu item to system menu.

// IDM_ABOUTBOX must be in the system command range.
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
ASSERT(IDM_ABOUTBOX < 0xF000);

CMenu* pSysMenu = GetSystemMenu(FALSE);
if (pSysMenu != NULL)
{
CString strAboutMenu;
strAboutMenu.LoadString(IDS_ABOUTBOX);
if (!strAboutMenu.IsEmpty())
{
pSysMenu->AppendMenu(MF_SEPARATOR);
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
}
}

// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon

// TODO: Add extra initialization here

return TRUE; // return TRUE unless you set the focus to a control
}

void CDlgtestDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
if ((nID & 0xFFF0) == IDM_ABOUTBOX)
{
CAboutDlg dlgAbout;
dlgAbout.DoModal();
}
else
{
CDialog::OnSysCommand(nID, lParam);
}
}

// If you add a minimize button to your dialog, you will need the code below
// to draw the icon. For MFC applications using the document/view model,
// this is automatically done for you by the framework.

void CDlgtestDlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // device context for painting

SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);

// Center icon in client rectangle
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;

// Draw the icon
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CDialog::OnPaint();
}
}

// The system calls this to obtain the cursor to display while the user drags
// the minimized window.
HCURSOR CDlgtestDlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}

void CDlgtestDlg::OnButton1()
{
CDlg2 dlg(this);
dlg.DoModal();
}
***************************************************************

#if !defined(AFX_DLG2_H__11E9112B_9C78_4698_9C02_403F39EEE0FA__INCLUDED_)
#define AFX_DLG2_H__11E9112B_9C78_4698_9C02_403F39EEE0FA__INCLUDED_

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

/////////////////////////////////////////////////////////////////////////////
// CDlg2 dialog
class CDlgtestDlg;
class CDlg2 : public CDialog
{
// Construction
public:
CDlg2(CWnd* pParent = NULL); // standard constructor
CDlg2(CDlgtestDlg* pDlg, CWnd* pParent = NULL); // standard constructor
// Dialog Data
//{{AFX_DATA(CDlg2)
enum { IDD = IDD_DIALOG1 };
// NOTE: the ClassWizard will add data members here
//}}AFX_DATA
CDlgtestDlg* m_pDlg1;

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

// Implementation
protected:

// Generated message map functions
//{{AFX_MSG(CDlg2)
// NOTE: the ClassWizard will add member functions here
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};

//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_DLG2_H__11E9112B_9C78_4698_9C02_403F39EEE0FA__INCLUDED_)
****************************************************************

// Dlg2.cpp : implementation file
//

#include "stdafx.h"
#include "dlgtest.h"
#include "Dlg2.h"

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

/////////////////////////////////////////////////////////////////////////////
// CDlg2 dialog


CDlg2::CDlg2(CWnd* pParent /*=NULL*/)
: CDialog(CDlg2::IDD, pParent)
{
//{{AFX_DATA_INIT(CDlg2)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
}

CDlg2::CDlg2(CDlgtestDlg* pDlg, CWnd* pParent /*=NULL*/)
:CDialog(CDlg2::IDD,pParent)
{
m_pDlg1 = pDlg;
}
void CDlg2::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CDlg2)
// NOTE: the ClassWizard will add DDX and DDV calls here
//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CDlg2, CDialog)
//{{AFX_MSG_MAP(CDlg2)
// NOTE: the ClassWizard will add message map macros here
//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CDlg2 message handlers


If it's broken, I probably did it

bdiamond
GeneralRe: MFC dialog member sharing? (code included) Pin
Christophocles4-Mar-04 10:27
sussChristophocles4-Mar-04 10:27 
GeneralRe: MFC dialog member sharing? (code included) Pin
BlackDice5-Mar-04 3:49
BlackDice5-Mar-04 3:49 
GeneralRe: MFC dialog member sharing? (or, My Marathon Ineptitude) Pin
Christophocles5-Mar-04 4:41
sussChristophocles5-Mar-04 4:41 
GeneralRe: MFC dialog member sharing? (or My Enduring Ineptitude) Pin
Christophocles5-Mar-04 6:25
sussChristophocles5-Mar-04 6:25 
GeneralRe: MFC dialog member sharing? (or My Enduring Ineptitude) Pin
BlackDice5-Mar-04 10:43
BlackDice5-Mar-04 10:43 
GeneralRe: MFC dialog member sharing? Pin
Christophocles5-Mar-04 12:01
sussChristophocles5-Mar-04 12:01 
GeneralRe: MFC dialog member sharing? Pin
Christophocles8-Mar-04 8:01
sussChristophocles8-Mar-04 8:01 
GeneralAdvice required.... Pin
slyone3-Mar-04 10:54
slyone3-Mar-04 10:54 
GeneralRe: Advice required.... Pin
Roger Allen4-Mar-04 6:55
Roger Allen4-Mar-04 6:55 
GeneralRe: Advice required.... Pin
slyone4-Mar-04 12:02
slyone4-Mar-04 12:02 
GeneralUNWANTED DEBUG OF LIBRARY FUNCTIONS Pin
cnd120013-Mar-04 10:36
cnd120013-Mar-04 10:36 
GeneralRe: UNWANTED DEBUG OF LIBRARY FUNCTIONS Pin
Rick York3-Mar-04 11:09
mveRick York3-Mar-04 11:09 
GeneralRe: UNWANTED DEBUG OF LIBRARY FUNCTIONS Pin
Tom Larsen3-Mar-04 11:23
Tom Larsen3-Mar-04 11:23 
GeneralRe: UNWANTED DEBUG OF LIBRARY FUNCTIONS Pin
cnd120013-Mar-04 11:58
cnd120013-Mar-04 11:58 
GeneralRe: UNWANTED DEBUG OF LIBRARY FUNCTIONS Pin
Christian Graus3-Mar-04 16:47
protectorChristian Graus3-Mar-04 16:47 
GeneralRe: UNWANTED DEBUG OF LIBRARY FUNCTIONS Pin
Tom Larsen4-Mar-04 5:04
Tom Larsen4-Mar-04 5:04 
GeneralRe: UNWANTED DEBUG OF LIBRARY FUNCTIONS Pin
Jonas Larsson4-Mar-04 4:45
Jonas Larsson4-Mar-04 4:45 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.