MDI, Document Title

I am just starting to develop an estimating application, which is going to be MDI, and when I set the document title, the tile in the windows does not update.

When the application first starts, the main view checks to see if the document is valid, if not prompts the user to select a valid document from a list. After the item is selected from the list, the variables in the document are set, the title created and the document title is set.

Problem is the window title still says :

TPGEstimating - TGPEst1

Any ideas?

void CDlgEstimateListing::OnSelect()
{
int nSelection = m_cEstimates.GetNextItem(-1, LVNI_SELECTED);
if(nSelection >= 0)
{
m_pDocument->m_nEstimate = atoi(m_cEstimates.GetItemText(nSelection, 0));
m_pDocument->m_nAffiliate = atoi(m_cEstimates.GetItemText(nSelection, 1));
m_pDocument->m_nProject = atoi(m_cEstimates.GetItemText(nSelection, 2));
m_pDocument->m_csProjectName = m_cEstimates.GetItemText(nSelection, 3);

CString csTitle;
csTitle.Format("Estimate : %04d Project ID : %04d Project : %s",
m_pDocument->m_nEstimate,
m_pDocument->m_nProject,
m_pDocument->m_csProjectName);
m_pDocument->SetTitle(csTitle);
}
CDialog::OnOK();
}

Mike B
[1344 byte] By [MikeB] at [2007-11-18 19:16:47]
# 1 Re: MDI, Document Title
I added a button to each document view which sets the document title exactly as above and the text then gets updated.
What does this mean?

E.G.,

void CFormTakeoff::OnShowWindow(BOOL bShow, UINT nStatus)
{
if(bShow)
{
if(GetDocument()->m_nEstimate <= 0)
{
CDlgEstimateListing dlg(NULL, m_pConnection, GetDocument());
if(dlg.DoModal() == IDOK)
{
CTPGEstimatingDoc* pDoc = GetDocument();

CString csTitle;
csTitle.Format("Estimate : %04d Project ID : %04d Project : %s",
pDoc->m_nEstimate,
pDoc->m_nProject,
pDoc->m_csProjectName);

pDoc->SetTitle(csTitle); // Window titles do not get updated! }
}
}
CFormView::OnShowWindow(bShow, nStatus);
}

void CFormTakeoff::OnUpdateTitle()
{
CString csTitle;
csTitle.Format("Estimate : %04d Project ID : %04d Project : %s",
GetDocument()->m_nEstimate,
GetDocument()->m_nProject,
GetDocument()->m_csProjectName);
GetDocument()->SetTitle(csTitle); // Updated!!!
}

Any ideas?

MikeB
MikeB at 2007-11-11 1:17:58 >
# 2 Re: MDI, Document Title
Check out KB99182 on MSDN. It seems to answer your question.
kirants at 2007-11-11 1:19:04 >