Jump to content
  • Advertisement
Sign in to follow this  
ArchG

Changing the Title Bar in MFC!?!? [RESOLVED]

This topic is 4812 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello, I was recently asked to write a small program. Since the program is rather small I thought I'd use MFC to write it. I've never used MFC before, but how hard could it be right?? Well after screwing around for like an hour, I still cannot find out how to change the Window Title Bar. I know this is probably something simple, but I can't find. I have tried changing the CREATESTRUCT cs structures WindowName member but that doesn't do anything...the title bar constantly sticks at "untitled - AppName" Any help on this issue would be appreciated. Thanks, ArchG [Edited by - ArchG on September 14, 2005 5:55:50 PM]

Share this post


Link to post
Share on other sites
Advertisement
Yes,
this->SetWindowTextW(_T("blah blah"));


causes an assert failure...I'm not really sure why it did that, so I just assumed that was not the way to change the title bar text..I'll mess around with it some more I guess..
Is there another way to change it? Or where should I be calling that?

I did it in the PreCreateWindow function of the MainFrm.cpp

Thanks for your reply SiCrane,
ArchG

Share this post


Link to post
Share on other sites
Whatever you named your project, let's say MFCTest, open up that cpp file. For exmaple, MFCTest.cpp. Scroll down to the InitInstance function. At the bottom of that function, simply add in m_pMainWnd->SetWindowText( "Your Caption Here" ); and you will have changed the title. They was using the function as SiCrane mentioned, but you need to call it from your main App class. I'm sure you could find other places to put it as well, but I just tried that and it worked fine for me.

Share this post


Link to post
Share on other sites
The problem is that internally, SetWindowText() causes a WM_SETTEXT message to be sent to the window. PreCreateWindow() is called before the window is created. You just need to put the call to SetWindowText() sometime after the window is created; it doesn't need to be called from the app class. OnCreate() should work as well.

Share this post


Link to post
Share on other sites
Quote:
Original post by SiCrane
OnCreate() should work as well.


Strangely enough, it does not work in MFC in VS7. I tried adding it in various posistions of the int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) function (the only OnCreate function by default) and it didn't work. I veen tried changing the lpCreateStruct's member of lpszName and same deal. I know when you use a Dialog based MFC app, you can add it to the BOOL Class::OnInitDialog() function, and that's where that goes. As for where else it can be changed, I can't seem to find anywhere.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!