Click to See Complete Forum and Search --> : How to Change DialogBox Title?


Viju
April 8th, 1999, 11:59 PM
In my program i am invoking the same dialogbox for four different Items. So depending on the
item i want to change the Title . how can i do it?

Masaaki
April 9th, 1999, 12:18 AM
Hi.

this->SetWindowText("Your Title");
Or we can omit this.
So, SetWindowText("Your Title");

Hope for help.
-Masaaki Onishi-

Viju
April 9th, 1999, 12:39 AM
the dialogbox is invoked from Mainframe.
so i can't use this->.
void CMainFrame::OnChangeGroup()
{
CSetUpDlg tDlg;
tDlg.DoModal();

}

void CMainFrame::OnChangePhase()
{
CSetUpDlg tDlg;
tDlg.DoModal();

}
tDlg.SetWindowText() gives some assertion failure.

Viju
April 9th, 1999, 01:02 AM
i got it.
i can do it on OnInitDialog() ;
thanks for your help.
Viju

mayflwer
April 20th, 1999, 05:18 AM
In that case do the following procedure.
for example, CInvoker is a dialog invoking a InvokedDlg whose title is
supposed to be changed.

CInvoker::Test1()
{
CInvokedDlg InvokedDlg;

// key position before DoModal()
InvokedDlg.GetTitle("Title that I want to change");

if(InvokerDlg.DoModal() == IDOK)
{
...
}
}
-----------------
class CInvokedDlg : public CDialog
{
...
private:
CString m_pTitle;
...
}


CInvokedDlg::CInvokedDlg(Wnd* pParent.....) // constructer
{
// insert the following line.
m_pTitle = _T("");
}

void CInvokedDlg::GetTitle(CString szTitle)
{
m_pTitle = szTitle;
}

BOOL CAlertDlg::OnInitDialog()
{
CDialog::OnInitDialog();

SetWindowText(m_pTitle); // insert to change the title

return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}

P.S.: 4 hours has passed to know this solution. ^)^