|
-
June 14th, 1999, 05:30 AM
#1
Window Caption
hai
How i can change my window caption in my Mdi Application.......
Iam using the command
::SetWindowText(AfxGetMainWnd()->m_hWnd,"HELLO";
Problem is the caption is apprearing as HELLO-untitled1
i don't want that "untitled1" i want simply want HELLO
pl. suggest me.
suchitra.
-
June 14th, 1999, 06:08 AM
#2
Re: Window Caption
goto the precreatewindow function and put this code:
cs.style &= ~FWS_ADDTOTITLE;
cs.lpszName = "My Name";
-
June 14th, 1999, 06:51 AM
#3
Re: Window Caption
hai
Thankyou for you respons...my problem is single document multipleview...each view i want
seperate caption......pl. suggest me
suchitra.
-
June 14th, 1999, 06:57 AM
#4
Re: Window Caption
Combine your method with ric's - his suggestion stops the 'Untitled1' from appearing, but in the OnActivateFrame() override for each child frame you can do what you originally said - change the title from there. It should stay as you put it, then.
-
June 14th, 1999, 08:37 AM
#5
Re: Window Caption
Hai Jason Teagle
Thank you for your response...as you suggested i tried but iam not getting that One more problem
is when i uncheck the Option in View->Toolbar My window caption is becoming Empty..can you pl.
suggest me.
Suchitra......
-
June 15th, 1999, 02:40 AM
#6
Re: Window Caption
For some reason the View menu seems deeply embedded in the MFC framework, so you can't easily get to it. So, to make sure that the frame has a title when you have the View - Toolbar item unchecked, you need to override CMainFrame's OnCommand() method (available in Class Wizard), and add the following code in that override:
--- CMenu *pMenu, *pSubMenu = NULL ;
int iState = -1 ;
// There is no point in letting the framework do its stuff first, because the
// menu item still won't be checked at this point - it requires idle time to
// update - so we must check the state BEFORE the toggle.
if (LOWORD(wParam) == ID_VIEW_TOOLBAR)
{
pMenu = GetMenu();
if (pMenu != NULL)
// pSubMenu = SubMenuFromID(pMenu, ID_VIEW_TOOLBAR);
// if (pSubMenu != NULL)
{
// iState = pSubMenu->GetMenuState(ID_VIEW_TOOLBAR,
// MF_BYCOMMAND);
iState = pMenu->GetMenuState(ID_VIEW_TOOLBAR,
MF_BYCOMMAND);
}
if (iState == -1 || (iState & MF_CHECKED) )
SetWindowText("Default Title");
}
---
You'll notice that I commented out some lines. I expected GetMenuState() to only return a valid state if the ID actually existed in that particular menu - so I wrote an elaborate routine to scan submenus to find the ID - but it turns out that it can return the state of the ID no matter how nested it is, as long as it is a unique ID.
This makes me feel stupid, because yesterday I advised someone that their GetMenuState() wasn't working because they were trying to use the wrong submenu - and I was wrong!
Anyway, this should solve your problem, although you need to check the View - Toolbar menu state when you change the window title as child frames are activated, otherwise they will change its title regardless of the state of the menu item.
-
June 15th, 1999, 05:49 AM
#7
Re: Window Caption
hello Jason Teagle ,
I tried the code which you suggest......the problem is the window caption is apprearing and
immediately disappearing. waititng for your suggestion
Suchitra.
-
June 15th, 1999, 05:58 AM
#8
Re: Window Caption
Add this call:
cmdInfo.m_nShellCommand = CCommandLineInfo::FileNothing
just before the call to ProcessShellCommand in the app's InitInstance.
HTH
Pashka
-
June 15th, 1999, 02:17 PM
#9
Re: Window Caption
I think I misled you slightly in where to change the main window's title - please remove the code from CChildFrame::OnActivateFrame() and instead, place it in CChildFrame::OnMDIActivate() (add a handler for WM_MDIACTIVATE). You should check to see if the bActivate parameter is TRUE, since you don't want the main window's title changed when a child is becoming inactive.
Now, once you have done that, let's just go over what you have so far. If I understand it correctly, when you click each child frame you want the main frame's title to show a different caption for each frame, and nothing else. You should have this now, have you? Or is this where the title goes blank immediately?
Now, can I ask, why did you talk about the View - Toolbar menu option? Are you trying to use this to control the window title in some way (how?), or did you just mean that you happened to choose that menu item and it caused the window title to go blank? Perhaps if you explain exactly how you want the main window title to behave as you open and close child frames, and operate the program, it might make it clearer.
Rather than keep posting on this thread, why don't you e-mail me ([email protected]) with your answers.
-
December 1st, 1999, 04:52 AM
#10
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|