[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1937
  • Last Modified:

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
0
marb
Asked:
marb
  • 3
  • 2
1 Solution
 
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
 
AxterCommented:
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
 
marbAuthor Commented:
It works...

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

Martin
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now