-
October 1st, 2011, 01:05 PM
#1
Are there any problem if I use GetMDIActiveDocument in OnInitDialog?
Hi,
Are there any problem if I use GetMDIActiveDocument in OnInitDialog?
I have this metho:
Code:
BOOL CDlgForm::OnInitDialog()
{
CDialogEx::OnInitDialog();
CAdestDoc* pDoc = GetMDIActiveDocument();
ASSERT_VALID(pDoc);
CString titulo = pDoc->GetTitle ();
CString aux;
CRect r;
m_Lista_Caract.GetWindowRect (&r);
m_Lista_Caract.InsertColumn (0, _T(" "), LVCFMT_LEFT, r.Width () -5);
m_Lista_Caract.DeleteAllItems ();
if (titulo.Right (4) == ".ped")
{
// Hemos abierto un archivo
// Mostramos sus caracterĂ*sticas
m_Lista_Caract.InsertItem (0, _T(""));
aux.Format (_T("\t Espacio de trabajo: %s"), titulo);
m_Lista_Caract.InsertItem (1, aux);
aux.Format (_T("\t \t NĂșmero de variables: %d"), pDoc->Variables.GetSize ());
m_Lista_Caract.InsertItem (2, aux);
aux.Format (_T("\t \t NĂșmero de informes: %d"), pDoc->Informes.GetSize ());
m_Lista_Caract.InsertItem (3, aux);
}
else
m_Lista_Caract.InsertItem (0, _T("Espacio de trabajo vacĂ*o"));
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPCIĂN: las pĂĄginas de propiedades OCX deben devolver FALSE
}
I use GetMDIActiveDocument in other method and there aren't problem, but in this method I get this error:
Error 1 error C3861: 'GetMDIActiveDocument': didn't find the identifier
-
October 1st, 2011, 01:56 PM
#2
Re: Are there any problem if I use GetMDIActiveDocument in OnInitDialog?
Did you include the appropriate header?
-
October 1st, 2011, 02:59 PM
#3
Re: Are there any problem if I use GetMDIActiveDocument in OnInitDialog?
Originally Posted by a343
Hi,
Are there any problem if I use GetMDIActiveDocument in OnInitDialog?
...
I get this error:
Error 1 error C3861: 'GetMDIActiveDocument': didn't find the identifier
What is GetMDIActiveDocument?
Where does it come from?
Victor Nijegorodov
-
October 1st, 2011, 09:22 PM
#4
Re: Are there any problem if I use GetMDIActiveDocument in OnInitDialog?
A better approach is to just pass the document pointer in the constructor of CDlgForm.
-
October 1st, 2011, 10:07 PM
#5
Re: Are there any problem if I use GetMDIActiveDocument in OnInitDialog?
Originally Posted by VictorN
What is GetMDIActiveDocument?
Where does it come from?
It's in the faq here.
http://www.codeguru.com/forum/showthread.php?t=473808
-
October 2nd, 2011, 04:04 AM
#6
Re: Are there any problem if I use GetMDIActiveDocument in OnInitDialog?
-
October 2nd, 2011, 04:29 AM
#7
Re: Are there any problem if I use GetMDIActiveDocument in OnInitDialog?
Originally Posted by ovidiucucu
Originally Posted by GCDEF
Huh!?
I didn't know my humble function already included in the MFC framework.
I didn't know it either!
So I only searched MSDN for it... without success.
Anyway...
Originally Posted by a343
Hi,
Are there any problem if I use GetMDIActiveDocument in OnInitDialog?
I have this metho:
Code:
BOOL CDlgForm::OnInitDialog()
{
CDialogEx::OnInitDialog();
CAdestDoc* pDoc = GetMDIActiveDocument();
ASSERT_VALID(pDoc);
CString titulo = pDoc->GetTitle ();
...
}
Yes, there are:
- You have to be sure the return value of GetMDIActiveDocument points the the object of CAdestDoc class (or of some class derived from it) like Ovidiu pointed out in his FAQ
- You have to cast the return value of GetMDIActiveDocument to your CAdestDoc type
But better solution was suggested by Arjay:
Originally Posted by Arjay
A better approach is to just pass the document pointer in the constructor of CDlgForm.
Victor Nijegorodov
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|