set title of MDI child frame

Hi,

I created an MDI project using the wizard, without support for doc/view architecture.

How do I set the title of the child frame (on its title bar), and how do I change its document name (even though it doesnt have a document) so it shows the same name as in the title bar in the 'window' menu, and on the mainframe title bar?

So far I only got the titlebar to update.

Thanks
DJ_AM_JuiceboxAsked:
Who is Participating?
 
mipkoCommented:
If I understood you correctly, you want both MDIChild and MainForm to have exact same title ?
You can achieve this in two ways

1. Edit Resources - String Table - IDR_MAINFRAME and IR_cvbType

2. do some coding

for mainframe:

void CMainFrame::OnUpdateFrameTitle(BOOL bAddToTitle)
{
      SetWindowText("Test Application");
}

you have to add one line in OnCreate right before return 0

SetWindowText("Test Application");


for MDIChild :

void CChildFrame::OnUpdateFrameTitle(BOOL bAddToTitle)
{
      SetWindowText("Test Application");
}

although when you maximize child window you will get Test Application[Test Application] in mainframe title.

regards
Mirko
0
 
mipkoCommented:
Override OnUpdateFrameTitle method in your CChildFrame and in CmainFrame.
In that method use SetWindowText to set form title as you desire.
You may comment default call and leave only your code.
0
 
DJ_AM_JuiceboxAuthor Commented:
That doesn't seem to work.

This is what I have so far when creating my child frame:

CMainFrame* pFrame = STATIC_DOWNCAST(CMainFrame, m_pMainWnd);
      CChildFrame* pChildFrame = (CChildFrame*)pFrame->CreateNewChild(RUNTIME_CLASS(CChildFrame), IDR_Test_WindoTYPE, m_hMDIMenu, m_hMDIAccel);
    pChildFrame->SetWindowText("Sample");
    pChildFrame->SetTitle("Sample");

Now the title on the child frame is correct, it is correct in the 'window' menu, only the main frame title is incorrect. As soon as I start to resize the child frame though, the main frame magically sets its title correctly - not sure what's going on with that.
0
Cloud Class® Course: Amazon Web Services - Basic

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

 
DJ_AM_JuiceboxAuthor Commented:
after blugeoning my application enough, this seems to work:

CMainFrame* pFrame = STATIC_DOWNCAST(CMainFrame, m_pMainWnd);
      CChildFrame* pChildFrame = (CChildFrame*)pFrame->CreateNewChild(RUNTIME_CLASS(CChildFrame), IDR_Test_WindoTYPE, m_hMDIMenu, m_hMDIAccel);
    pChildFrame->SetWindowText("Test");
    pChildFrame->SetTitle("Test");
    pFrame->UpdateFrameTitleForDocument("Test");

SetWindowText() seems to set the title of the frame.
SetTitle() seems to set the title of the document (even though there isn't one).
UpdateFrameTitleForDocument() sets the initial title of main frame correctly so its app name + my desired frame title.

UpdateFrameTitleForDocument() would not be necessary if a size message were generated at frame creation - as soon as the frame is sized without that call main frame updates its title properly.

Can anyone explain these three calls? There must be an easier way to do this.

Thanks
0
 
DJ_AM_JuiceboxAuthor Commented:
Hi mipko,

Not exactly, I want:

    MainFrame - Title of Application + [Title of currently active frame]
    ChildFrame - Simple title for frame

I think this is the 'standard' MDI way, though in my case creating the project without using documents seems to have broken something.
0
 
mipkoCommented:
Hi DJ,

did you try with overloading OnTitleUpdate ?
I don't see the problem. Put whatever text you want in ChildFrame OnTitleUpdate and you will get ChildFrame with your desired title.
Put any text you want in OnTitleUpdate for MainFrame and you will have Mainframe title as you wanted.
When you maximize mdichild you will get title like this MainFrameTitle[mdichildtitle}.

As I said in my previous comment you can edit resource strings if you want one timer fixed sollution.

M.
0
 
nksaxenaCommented:
call CDocument class's SetPathName() or SetTitle() method.

for example in your View class,
GetDocument()->SetTitle("This is new Title");


0
 
nksaxenaCommented:
Sorry. i missed that application is not supporting Doc-View arch
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.