SetWindowText for Caption title...? 
Author Message
 SetWindowText for Caption title...?

When you build an app, you end up with caption title which goes:

Untitled - YourAppName

I decided I wanted something more appropriate, but I can't figure out how to
set text in there... I've looked around in Help menu and found SetWindowText
which apparently changes "caption". I put SetWindowText( _T("testing testing"))
in CMainFrame::OnCreate but it didn't change anything.

Can you help?



Mon, 08 Dec 2003 11:18:00 GMT  
 SetWindowText for Caption title...?

Quote:

> When you build an app, you end up with caption title which goes:

> Untitled - YourAppName

> I decided I wanted something more appropriate, but I can't figure out how to
> set text in there... I've looked around in Help menu and found SetWindowText
> which apparently changes "caption". I put SetWindowText( _T("testing testing"))
> in CMainFrame::OnCreate but it didn't change anything.

> Can you help?

MFC is changing it after you change it (:

To turn this 'feature' off you can do:

BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
{
        cs.style &= ~FWS_ADDTOTITLE; // kill cutesy MFC titles
        return CFrameWnd::PreCreateWindow(cs);

Quote:
}

--
Scott McPhillips [VC++ MVP]


Mon, 08 Dec 2003 11:38:05 GMT  
 SetWindowText for Caption title...?
If You want to get rid of the '-YourAppName' You can remove the
FWS_ADDTOTITLE (cs.style&=~FWS_ADDTOTITLE;) in the MainFrame'd
PreCreateWindow().

If You want to change the text before '-YourAppName' You can use the doc's
SetTitle() function. I think this also will change the behaviour of SaveAs
by setting the default name to what You have set the title to.



Quote:
> When you build an app, you end up with caption title which goes:

> Untitled - YourAppName

> I decided I wanted something more appropriate, but I can't figure out how
to
> set text in there... I've looked around in Help menu and found
SetWindowText
> which apparently changes "caption". I put SetWindowText( _T("testing
testing"))
> in CMainFrame::OnCreate but it didn't change anything.

> Can you help?



Tue, 09 Dec 2003 04:49:45 GMT  
 SetWindowText for Caption title...?
PugPenguin,

there is a virtual  (albeit undocumented)  method of CFrameWnd -
OnUpdateFrameTitle that might do the trick (it gives you ultimate control).
Set an override for it, and call the SetWindowTitle(...)  as below....

regards,
roy fine

//
// -------------------------------------------------------------------------
--
void CMainFrame::OnUpdateFrameTitle(BOOL bAddToTitle){
SetWindowText("Your Something Special");

Quote:
}



Quote:
> When you build an app, you end up with caption title which goes:

> Untitled - YourAppName

> I decided I wanted something more appropriate, but I can't figure out how
to
> set text in there... I've looked around in Help menu and found
SetWindowText
> which apparently changes "caption". I put SetWindowText( _T("testing
testing"))
> in CMainFrame::OnCreate but it didn't change anything.

> Can you help?



Tue, 09 Dec 2003 05:14:19 GMT  
 SetWindowText for Caption title...?


Wed, 18 Jun 1902 08:00:00 GMT  
 SetWindowText for Caption title...?
Thank you, that helps wonderfully. I had done quite some work on other aspects
of MFC and suddenly realised this "little" thing about caption was totally
alien to me. Now I get it :) Thanks everyone!


Wed, 10 Dec 2003 19:42:09 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. Why SetWindowText() not change window title?

2. How to change the whole title (caption) of a PropertyFrame created with OleCreatePropertyFrame

3. How can I change the color of the caption/title of a PropertyPage

4. CListView: Q1 - Show/Hide column and header, Q2 - Caption Title Bar

5. Modify Child Wnd Title Bar Caption in MDI App

6. different window caption in title and taskbar

7. Set Main Title Caption

8. CFileDialog --> title/caption

9. Doc-View w/o Caption/Title

10. An Easy One...(Changing Title Bar Caption)

11. DialogBox Caption Title

12. Title in SDI Title Bar

 

 
Powered by phpBB® Forum Software