
Q: Changing a dialog box's title text
Couple of things:
1. Put the title in the constructor of your dialog.
CABCDlg(CString& title, CWnd* pParent = NULL);
and hide the dialog variable:
private:
CString m_dialogTitle.
This way, in the constructor you can set m_dialogTitle to the one passed in
the constructor.
2. If you did not want to do above suggestion, provid a access method for
your title:
CString& GetTitle(){ return m_dialogTitle;}
void SetTitle(CString& title){m_dialogTitle = title;}
--
Ajay Kalra [MVP - VC++]
Note: Please post all replies to newsgroup only.
Quote:
> Thanks for your hint. One more question: I declared a variable in the
derived
> CDialog class' Dialog Data in the public area (see code below). This way
I can
> pass the title from the main program into the dialog: testDlg.dialogTitle
=
> _T("Test"); . It works fine, but I want to make sure if this is the
correct way
> to go. Thanks.
> class CABCDlg : public CDialog
> {
> public:
> CABCDlg (Cwnd* pParent = NULL);
> // Dialog Data
> file://{{AFX_DATA (CABCDlg)
> enum { IDD = <some ID> };
> CString dialogTitle; // <------******
> ...
> > SetWindowText() is the way to go, but you have to call it after the
window
> > was created, that is in InitDialog function after calling
> > CDialog::InitDialog().
> > Dan
> --
> --------------------------------------------------------------------------
> Please remove "REMOVE" when replying by email address. Thanks.