
Dialog box pop-up - SDI vs. MDI apps
I have a multiple document interface application where one child window
comes up. I'm trying to implement a simple application where when I
left click in the child window a dialog box pops up. I'm following a
mix of two examples. One on dialog boxes and one on MDI's. I create
the dialog resource and class and follow an example for a modeless dialog
box. I create a function for the left mouse click and during debug the
program gets there but no dialog box pops-up.
The project is caled Multi, and the dialog class is CSSDialog. Below are
some code fragments.
------------------------------------------------------------
SSDialog.h
----------
class CSSDialog : public CDialog
{
private:
CView* m_pView;
public:
CSSDialog(CView* pView);
BOOL Create();
// Construction
public:
CSSDialog(CWnd* pParent = NULL); // standard constructor
// Dialog Data
//{{AFX_DATA(CSSDialog)
enum { IDD = IDD_SS };
// NOTE: the ClassWizard will add data members here
//}}AFX_DATA
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CSSDialog)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
// Generated message map functions
//{{AFX_MSG(CSSDialog)
// NOTE: the ClassWizard will add member functions here
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
Quote:
};
//{{AFX_INSERT_LOCATION}}
// Microsoft Developer Studio will insert additional declarations
immediately before the previous line.
#endif //
!defined(AFX_SSDIALOG_H__4E95115B_11A6_11D2_8080_00C04F9E3A5D__INCLUDED_)
------------------------------------------------------------
SSDialog.cpp
------------
CSSDialog::CSSDialog(CView* pView) {
m_pView = pView;
Quote:
}
CSSDialog::CSSDialog(CWnd* pParent /*=NULL*/)
: CDialog(CSSDialog::IDD, pParent)
{
m_pView = NULL;
//{{AFX_DATA_INIT(CSSDialog)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
Quote:
}
BOOL CSSDialog::Create() {
return CDialog::Create(CSSDialog::IDD);
Quote:
}
------------------------------------------------------------
MultiView.h
-----------
class CSSDialog;
class CMultiView : public CView
{
private:
CSSDialog* m_pDlg;
protected: // create from serialization only
CMultiView();
DECLARE_DYNCREATE(CMultiView)
// Attributes
public:
CMultiDoc* GetDocument();
------------------------------------------------------------
MultiView.cpp
-------------
CMultiView::CMultiView()
{
// TODO: add construction code here
m_pDlg = new CSSDialog(this);
Quote:
}
CMultiView::~CMultiView()
{
delete m_pDlg;
Quote:
}
void CMultiView::OnLButtonDown(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
if (m_pDlg->GetSafeHwnd() == 0) {
m_pDlg->Create();
}
//CView::OnLButtonDown(nFlags, point);
Quote:
}
------------------------------------------------------------
My goal is to have a project window where I can have multiple dialog
boxes pop up from various pull down menu items. These dialog boxes
will be modeless so I can move between them and enter values/click
buttons, etc. Am I correct in assuming that I need an MDI for this????
Thank you.
Please also respond to