change the dilog title at runtime
Hi, everyone
I'm using visual c++ with many dialog classes. I want to change the dialog title at runtime. I used the SetWindowText() to do that but it changes also the main window title and I don't want that. Has anyone another idea?
Re: change the dilog title at runtime
Re: change the dilog title at runtime
SetWindowText is the right way, but you must call it for the appropriate window.
Show us your call and maybe we can spot the problem.
Re: change the dilog title at runtime
Quote:
Originally Posted by
florivucu
Help!!!!!
Don't be childish, have patience for people to answer. We are doing voluntary help here and you should keep that in mind. Don't expect that your questions are answered in 2 minutes.
Re: change the dilog title at runtime
I'm calling the SetWindowText in OnInitDialog() like that:
if (litera == "E")
{
SetWindowText("Estimare");
// somecode
}
else
SetWindowText("Calcul TUI manual ");
Re: change the dilog title at runtime
Yes, that should change the title of the dialog on whose class you have that code.
Re: change the dilog title at runtime
Yes, but it changes also the main window dialog title. The main window caontains the menu and a map.
Re: change the dilog title at runtime
Quote:
Originally Posted by
florivucu
I'm calling the SetWindowText in OnInitDialog() like that:
That line seems wrong.
What is litera? Is it a char? If yes - then you should use apostrophes:If it is char array (or char*) then use strcmp function
Re: change the dilog title at runtime
litera it's a char but seems to work ok because it changes the name the way I llike. What I don't like is that it changes the name of the main window, that with the menu.
Re: change the dilog title at runtime
Quote:
Originally Posted by
florivucu
litera it's a char but seems to work ok because it changes the name the way I llike. What I don't like is that it changes the name of the main window, that with the menu.
pass the windows handle of appropriate window.Like this
Code:
::SetWindowText(hwnd,"Run Time change");
Re: change the dilog title at runtime
I'm quite confused. Is it possible that you post a screenshot of the window?
Re: change the dilog title at runtime
I don't have a pointer hwnd for the dialog. I tried to use "this" but I've got a sintax error; using another pointer I've got " the dialog is already opened".
My application works like that: I have a main window which remanins on top, with the menu. From the menu I'm calling the dialogs. In OnUpdateMyDialog () the dialog is opened and go on with the code. The SetWindowText changes the name of the dialog but it changes also the name of the main window. That's my problem.
Re: change the dilog title at runtime
how can I do that? to add a jpeg?
Re: change the dilog title at runtime
Quote:
Originally Posted by
florivucu
I don't have a pointer hwnd for the dialog. I tried to use "this" but I've got a sintax error; using another pointer I've got " the dialog is already opened".
My application works like that: I have a main window which remanins on top, with the menu. From the menu I'm calling the dialogs. In OnUpdateMyDialog () the dialog is opened and go on with the code. The SetWindowText changes the name of the dialog but it changes also the name of the main window. That's my problem.
ok can you show here code?
Re: change the dilog title at runtime
what exactly do you want to see? the code is too large so....
Re: change the dilog title at runtime
Quote:
Originally Posted by
florivucu
what exactly do you want to see? the code is too large so....
Create a hwnd of child dialog and SetWindowText part.
Re: change the dilog title at runtime
I do not know how to create a hwnd of the dialog. Can you tell me? In the cosntructor of the dialog I have the Create (MyClass::IDD, pParent). Creating another pointer to the class would not generate the error I've got?
Re: change the dilog title at runtime
ok can you tell here what you want to do?.When you call SetWindowText?
Re: change the dilog title at runtime
In the MainWindow (in the menu) I'm calling the same dialog for two different menus:Estimare and Calcul Tui Manual. Depending on what I choose I want to set the title of the dialog according to the menu. I've done that with SetWindowText but this command changes the name of the main window called "Calipso - bla bla". I tried to use a parameter (&ttitle)in the caption of the dialog but I could not set it properly. In the OnEstim function (Mainframe menu) I have
.....
litera = "E";
{
...... new CTuiDataInputDlg(this); // the dialog class
this->SetWindowText("Estimare"); this is not working
........ }
.......
In the OnInitDialog of the class I have those line with SetWindowText.
Re: change the dilog title at runtime
Quote:
Originally Posted by
florivucu
In the MainWindow (in the menu) I'm calling the same dialog for two different menus:Estimare and Calcul Tui Manual. Depending on what I choose I want to set the title of the dialog according to the menu. I've done that with SetWindowText but this command changes the name of the main window called "Calipso - bla bla". I tried to use a parameter (&ttitle)in the caption of the dialog but I could not set it properly. In the OnEstim function (Mainframe menu) I have
.....
litera = "E";
{
...... new CTuiDataInputDlg(this); // the dialog class
this->SetWindowText("Estimare"); this is not working
........ }
.......
In the OnInitDialog of the class I have those line with SetWindowText.
Before or after the call to CDialog::OnInitDialog()? If it's before, move it after.
litera = "E" Are you sure you want to use an assignment operator there? You should provide more information when asked. It seems you have other problems too.
Re: change the dilog title at runtime
Quote:
Originally Posted by
florivucu
In the MainWindow (in the menu) I'm calling the same dialog for two different menus:Estimare and Calcul Tui Manual. Depending on what I choose I want to set the title of the dialog according to the menu. I've done that with SetWindowText but this command changes the name of the main window called "Calipso - bla bla". I tried to use a parameter (&ttitle)in the caption of the dialog but I could not set it properly. In the OnEstim function (Mainframe menu) I have
.....
litera = "E";
{
...... new CTuiDataInputDlg(this); // the dialog class
this->SetWindowText("Estimare"); this is not working
........ }
.......
In the OnInitDialog of the class I have those line with SetWindowText.
WHERE IS THIS CODE FROM? I see you create a new dialog and set "this" as its parent. But then you call SetWindowText() for "this", which is the parent. Is this "this" the main frame? Then of course you change the title of the main frame, for god's sake.
Re: change the dilog title at runtime
OK. You are very right. I forgot those line. Now it is ok. Thanks. And sorry for my stupid questions.