Accessing CDucument from CDialogBar
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.
Re: CDocumant is not a parent of CDialogBar, it is ReBar.
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-