Click to See Complete Forum and Search --> : change Caption on a DialogBox


AndiL
August 5th, 2004, 06:29 AM
HI,

I provided two dialogue boxes. Now I would like to change the caption (title) of the second dialogue box after an input in the first dialogue box.
How can I do that?

Thanks for help
AndiL

Andreas Masur
August 5th, 2004, 06:58 AM
Pass the title to the second dialog...in 'OnInitDialog' of the second one you then set the title...for example...

// Dialog2.hpp
class CDialog2 : public CDialog
{
public:
...

//{{AFX_VIRTUAL(CDialog2)
public:
virtual int DoModal(const CString& Title);
protected:
virtual void DoDataExchange(CDataExchange *pDX);
//}}AFX_VIRTUAL

private:
CString m_Title;
};

// Dialog2.cpp
int CDialog2::DoModal(const CString& Title)
{
// Initialization
m_Title =Title;

return CDialog::DoModal();
}

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

SetWindowText(m_Title);

return TRUE;
}

// CDialog1.cpp
void CDialog1::OnButtonClick()
{
UpdateData();

// Create second dialog and pass input
CDialog2 dlg;
dlg.DoModal(m_Title);
}