CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 8 of 8
  1. #1
    Join Date
    Nov 2004
    Posts
    1

    Changing an application title

    Hi - Im programming a Doc-View project, and couldnt find how to change the application title from "XXXXX - Untitled" to just "XXXXX"

    Can anyone assist ?
    Thanks
    Timor

  2. #2
    Join Date
    May 2005
    Posts
    4,954

    Re: Changing an application title

    Look at ::SetWindowText ( ) api.

    Cheers
    Shahar

  3. #3
    Join Date
    Apr 2005
    Posts
    247

    Re: Changing an application title

    No I am almost sure SetWindowText would not work, use SetTitle in Document class initialization instead.

    Regards
    Ashwin

  4. #4
    Join Date
    May 1999
    Location
    ALABAMA, USA
    Posts
    9,917

    Re: Changing an application title

    I think it is XXXXX – Untitled for SDI application.
    Code:
    BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
    {
    	if( !CFrameWnd::PreCreateWindow(cs) )
    		return FALSE;
    	// TODO: Modify the Window class or styles here by modifying
    	//  the CREATESTRUCT cs
    	cs.style &= ~FWS_ADDTOTITLE;
    	return TRUE;
    }
    There are only 10 types of people in the world:
    Those who understand binary and those who do not.

  5. #5
    Join Date
    Oct 2002
    Location
    Timisoara, Romania
    Posts
    14,360

    Re: Changing an application title

    Quote Originally Posted by AshwinRao
    No I am almost sure SetWindowText would not work
    Yes, it works...
    Marius Bancila
    Home Page
    My CodeGuru articles

    I do not offer technical support via PM or e-mail. Please use vbBulletin codes.

  6. #6
    Join Date
    Apr 2005
    Posts
    247

    Re: Changing an application title

    Please tell me how and where you got it working. Try to paste a snippet with the function and the class where you got it working. And moreover I was speaking renaming the Child Windows, the poster has not specified what is to be renamed.

    Regards
    Ashwin
    Last edited by AshwinRao; May 24th, 2005 at 08:05 AM.

  7. #7
    Join Date
    May 1999
    Location
    ALABAMA, USA
    Posts
    9,917

    Re: Changing an application title

    To clarify:
    It will work only for SDI application it will not work for MDI application since title of the main frame window is updated when active child window changes.
    There are only 10 types of people in the world:
    Those who understand binary and those who do not.

  8. #8
    Join Date
    Oct 2002
    Location
    Timisoara, Romania
    Posts
    14,360

    Re: Changing an application title

    Quote Originally Posted by AshwinRao
    Please tell me how and where you got it working. Try to paste a snippet with the function and the class where you got it working. And moreover I was speaking renaming the Child Windows, the poster has not specified what is to be renamed.
    He said:
    couldnt find how to change the application title
    To me that means main frame's text, which, as John explained, is changed each time the active child window changes.

    That doesn't mean you can't change it, if only temporary with SetWindowText().
    Code:
    AfxGetMainWnd()->SetWindowText("bla bla bla");
    anywhere you want, as long as the call is made from the GUI thread (so that AfxGetMainWnd returns a pointer to the main window).

    However, this will change when a new child window becomes active.
    Marius Bancila
    Home Page
    My CodeGuru articles

    I do not offer technical support via PM or e-mail. Please use vbBulletin codes.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured