Click to See Complete Forum and Search --> : Changing the caption on a modal dialog


Anders Eriksson
May 11th, 1999, 07:18 AM
I have tried to change the caption for a modal dialog with this code:

CMyDia dlg;
dlg.SetWindowsText("Hello World");
dlg.DoModal();




The code compiles and runs but the caption will not change. The CMyDia class is just a dialog with a static text. The class is created by ClassWizard.
The code is in a dll.
//Anders

mihai
May 11th, 1999, 07:34 AM
Call dlg.SetWindowsText("Hello World"); in dlg.OnInitDialog.
Sincerely, Mihai

Ashley Antony
May 11th, 1999, 08:39 AM
When you call SetWindowTExt() it will try to change the caption of an existing window. In the dialog case, window is created only when you call DoModal(). Till that time window doesn't exist, so calling SetWindowText() before DoModal() won't make any change. You do it in the InitDialog().

Ashley.Antony@in.bosch.com
B'lore
India.