Click to See Complete Forum and Search --> : Accessing CDucument from CDialogBar
ralph
March 31st, 1999, 09:28 AM
I have made a class derived from CDialogBar.
The DialogBar itself is created in the OnCreate
method of the CFrameWnd class.
The dialogbar includes several buttons and edit-boxes.
Now I wanted to pass a integer-value from the DialogBar
to the Document-class like this:
CMyDoc *m_doc = (CMyDoc *)GetParent();
m_doc->value_in_document_class= 10;
With this pointer to the document class it is possible to
call methods of it, but if a value should be passed the
following assertion-error occurs in "barcore.cpp"
ASSERT(m_nCount == 0 || m_pData != NULL);
In my case the m_pData value is NULL.
Does anyone know a sollution for this problem.
Ralph
March 31st, 1999, 09:28 AM
I have made a class derived from CDialogBar.
The DialogBar itself is created in the OnCreate
method of the CFrameWnd class.
The dialogbar includes several buttons and edit-boxes.
Now I wanted to pass a integer-value from the DialogBar
to the Document-class like this:
CMyDoc *m_doc = (CMyDoc *)GetParent();
m_doc->value_in_document_class= 10;
With this pointer to the document class it is possible to
call methods of it, but if a value should be passed the
following assertion-error occurs in "barcore.cpp"
ASSERT(m_nCount == 0 || m_pData != NULL);
In my case the m_pData value is NULL.
Does anyone know a sollution for this problem.
Bore
March 31st, 1999, 09:41 AM
CWnd::GetParent() returns a CWnd*. You can't cast this to a CDocument*, because CDocument and CWnd aren't related. Assuming that you're creating the dialog from your view class, you could create a new constructor for the dialog that allows you to pass a CDocument* into it. Then you could construct your dialog thus:
CMyDialog dlg(GetDocument());
Masaaki Onishi
March 31st, 1999, 11:22 AM
Hi.
You misunderstand the relationship between CDcoument and CDialogBar.
Use SPY++ to figure it out.
One time I also check this. If I didn't forget, the parent of CDialogBar
is ReBar if you use App Wizard by generating CDialogBar.
By the way, if you want to bring the varaible to CDocument class, there must
be a couple of ways. If you can understand how apply button on Property page
works, you will solve this problem.
Basically, we brings CWnd of CDialogBar to CDocumet.
For cxample,
//CMyDocument class
public:
void GetOfWnd(CMyDialogBar *);
// its cpp
void CMyDocument::GetOfWnd(CMyDialogBar* m_Wnd)
{
p_nWnd = m_Wnd);
}
//CMyDialogBar class
CMyDialogBar::OnInitDialog()
{
......
((CMyDocument*)AfxGetMainWnd())->GetOfWnd(this);
}
//After this, CMyDocument class
p_nWnd->variable //From CMyDialogBar public member.
After I check the class wizard, I can't find CDialogBar class if I generate
CDialgBar itself. So you use the base class CDialog?
Because CDialogBar exists, it derived from CControlbar class. Therefore,
we can't use OnInitdialog function? In this case, the situation will be
changed.
Hope for help.
-Masaaki Onishi-
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.