CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7
  1. #1
    Join Date
    Aug 2001
    Posts
    81

    Change window name

    I would like to change the default name that appear at the the to of the window in a MDI application. I tried to use the function SetWindowText, it run but never change. I call it in the OnInitUpdate function of the window.

    Thanks

  2. #2
    Join Date
    May 2000
    Location
    Washington DC, USA
    Posts
    715

    Re: Change window name

    SetWindowText is the function which would do it. Make sure you're giving it the correct HWND. Or calling it in the applications init rather than one of the mdi child windows.

  3. #3
    Join Date
    Aug 2001
    Posts
    81

    Re: Change window name

    I call it directly in the OnCreate function of my window ( CMDIChildWnd). At the same place I call MoveWindow to resize it and it work.

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

    Re: Change window name

    Code:
    AfxGetMainWnd()->SetWindowText("19 MAY 2005");
    Marius Bancila
    Home Page
    My CodeGuru articles

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

  5. #5
    Join Date
    Aug 2001
    Posts
    81

    Re: Change window name

    Is it work with the title of a MDI Frame?

  6. #6
    Join Date
    Sep 2002
    Location
    14° 39'19.65"N / 121° 1'44.34"E
    Posts
    9,815

    Re: Change window name

    Quote Originally Posted by Geof
    Is it work with the title of a MDI Frame?
    No, since the MFC framework adds its own mechanism to automatically display the current document name in the MDI frame's caption. To turn off that feature, you'll have to add the following line to the main frame's PreCreateWindow() (before calling the base class implementation):
    Code:
    cs.style &= ~FWS_ADDTOTITLE;

  7. #7
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Location
    Florida
    Posts
    12,635

    Re: Change window name

    Quote Originally Posted by Geof
    I call it directly in the OnCreate function of my window ( CMDIChildWnd). At the same place I call MoveWindow to resize it and it work.
    CMDIChildWnd isn't the class for the application's main window. It's the frame for each individual view.

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