Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

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

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
0
DJ_AM_Juicebox
Asked:
DJ_AM_Juicebox
  • 3
  • 3
  • 2
1 Solution
 
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
 
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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
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
 
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

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

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