If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register or Login
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Hybrid View

How to change the title of CMDIFrameWnd when child is maximized ?

Hi,

As all you know, usually the title bar will show " AppTitle - [DocTitle] " . In my project, I want to
change it to "[DocTitle] - AppTitle".

I know the FWS_ADDTOTITLE and FWS_PREFIXTITLE settings. However, It only works when the MDI child is not maximized. When MDI child is maximized, the title
will restore to " AppTitle - [DocTitle] " format.

Hi!
I 've never tested this code in MDI, however in Dialog App it works fine (I use this code in InitInstance):

Code:

// change the AppName
//First free the string allocated by MFC at CWinApp startup.
//The string is allocated before InitInstance is called.
free((void*)m_pszAppName);
//Change the name of the application file.
//The CWinApp destructor will free the memory.
m_pszAppName=_tcsdup(_T("New_App_Title"));

Try to set you title this way in form " AppTitle - [DocTitle] " and don't forget to remove standard Doc name addition to the title.

Sorry. But I think your code can just change the word of the Title. My question is how to change the ordering from "AppTitle - [DocTitle]" to "[DocTitle] - AppTitle". when the MDI child frame is maximized.

Actually I can not find when and where the MainFrame's title is set. I find after I SetWindowText of a ChildFrame's title, the MainFrame's title is changed to "AppTitle - [DocTitle]" format. But I can not find out which part of the code causes the change from the MFC source code.

Originally posted by VictorN
Hi!
I 've never tested this code in MDI, however in Dialog App it works fine (I use this code in InitInstance):

Code:

// change the AppName
//First free the string allocated by MFC at CWinApp startup.
//The string is allocated before InitInstance is called.
free((void*)m_pszAppName);
//Change the name of the application file.
//The CWinApp destructor will free the memory.
m_pszAppName=_tcsdup(_T("New_App_Title"));

Try to set you title this way in form " AppTitle - [DocTitle] " and don't forget to remove standard Doc name addition to the title.

Using SetWindowText on CMainFrame only change the AppTitle part and override CMDIChildWnd::OnUpdateFrameTitle can only change the DocTitle part. What I am looking for is to change the ordering of AppTitle - [DocTitle] to [DocTitle] - AppTitle, not the actual words of them.

Originally posted by t2di4u
You can change your title by SetWindowText or override CMDIChildWnd::OnUpdateFrameTitle. The title is change in the fuction.

Thanks. It works ! But there is still a problem. If use your codes in my program, the CChildFrame will not have a title. I think what your code does is to make the CChildFrame's title to NULL and set the CMainFrame's title to required text. Except this problem, it works fine.

Originally posted by t2di4u
sorry , I forgot to tell you that you should get rid of the main frame's OnUpdateFrameTitle.

Thanks. But with above code, the old problem will come back again. When the CChildFrame is maximized its title will be appended to the MainFrame. Then the MainFrame's title will be "DocTitle - AppTitle - [DocTitle]" . You will know what I mean if you try to execute the code.