Change title (caption) of CDialog at runtime

Hi,

how can I change the caption of my CDialog instance at runtime?

Thank you in advance...
Martin
marbAsked:
Who is Participating?
 
AxterConnect With a Mentor Commented:
Example code:
BOOL NoteDialog::OnInitDialog()
{
      CDialog::OnInitDialog();

      // Set the icon for this dialog.  The framework does this automatically
      //  when the application's main window is not a dialog
      SetIcon(m_hIcon, TRUE);                  // Set big icon
      SetIcon(m_hIcon, FALSE);            // Set small icon
      
      // TODO: Add extra initialization here
      SetWindowText("Hello World");   //**********Put code here ***********************
      
      return TRUE;  // return TRUE  unless you set the focus to a control
}
0
 
AxterCommented:
Hi marb,
Call SetWindowText

David Maisonave :-)
Cheers!
0
 
marbAuthor Commented:
NoteDialog is the name of my dialog class.

When a button is clicked, I wan't to open the dialog. I did like this:

NoteDialog dlg;
dlg.DoModal();

This works, but if I add the line

NoteDialog dlg;
dlg.SetWindowText("Note1");
dlg.DoModal();

The app crashes!
0
 
AxterCommented:
Add the code to your OnInitDialog method in your Dialog class.
0
 
marbAuthor Commented:
It works...

Thank you Axter for your immidiate answer. It's great to have people like you on Experts Exchange!

Martin
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.