Update title in a CFrameWnd - Programmer

This is a discussion on Update title in a CFrameWnd - Programmer ; I've got a simple MFC program where I want to change the Window title. At the moment i've got this bit of code: wndtitle = "Jobber - " + current.playername; // appends CString SendMessage(WM_SETTEXT); that changes the variable (wndtitle) and ...

+ Reply to Thread
Results 1 to 6 of 6

Thread: Update title in a CFrameWnd

  1. Update title in a CFrameWnd

    I've got a simple MFC program where I want to change the Window title.
    At the moment i've got this bit of code:

    wndtitle = "Jobber - " + current.playername; // appends CString
    SendMessage(WM_SETTEXT);

    that changes the variable (wndtitle) and then sends this message which
    sounds right and looks right because when i run it the window title is
    eradicated. only thing is i don't know what function this message is
    calling so i can't put a SetWindowText(wndtitle) there.

    Thanks for any help,

    oLE

  2. Re: Update title in a CFrameWnd


    If you are using Document view architecture, you can change the title
    of your windows using the following code in the OnDraw function of your
    view:

    // Get the Document pointer
    CTestDoc* pDoc = GetDocument();
    pDoc->SetTitle("My Title");

    // you can also try the following:

    AfxGetApp()->m_pMainWnd->SetWindowText("My Title");

    -- Nand Kishore

    oLE wrote:
    > I've got a simple MFC program where I want to change the Window

    title.
    > At the moment i've got this bit of code:
    >
    > wndtitle = "Jobber - " + current.playername; // appends CString
    > SendMessage(WM_SETTEXT);
    >
    > that changes the variable (wndtitle) and then sends this message

    which
    > sounds right and looks right because when i run it the window title

    is
    > eradicated. only thing is i don't know what function this message is
    > calling so i can't put a SetWindowText(wndtitle) there.
    >
    > Thanks for any help,
    >
    > oLE



  3. Re: Update title in a CFrameWnd

    oLE wrote:

    > I've got a simple MFC program where I want to change the Window title.
    > At the moment i've got this bit of code:
    >
    > wndtitle = "Jobber - " + current.playername; // appends CString
    > SendMessage(WM_SETTEXT);
    >
    > that changes the variable (wndtitle) and then sends this message which
    > sounds right and looks right because when i run it the window title is
    > eradicated. only thing is i don't know what function this message is
    > calling so i can't put a SetWindowText(wndtitle) there.
    >
    > Thanks for any help,
    >
    > oLE


    In MFC SendMessage and SetWindowText are both members of CWnd. You are
    probably calling SendMessage in the context of your CFrameWnd class. So
    calling SetWindowText in the same class should work. You should install
    and look at the MFC source code: It is very helpful for both learning
    and debugging. MFC's SetWindowText is a trivial function that sends
    WM_SETTEXT to the class's m_hWnd.

    --
    Scott McPhillips [VC++ MVP]


  4. Re: Update title in a CFrameWnd

    kish_nand@yahoo.com wrote:
    > If you are using Document view architecture, you can change the title
    > of your windows using the following code in the OnDraw function of your
    > view:
    >
    > // Get the Document pointer
    > CTestDoc* pDoc = GetDocument();
    > pDoc->SetTitle("My Title");
    >
    > // you can also try the following:
    >
    > AfxGetApp()->m_pMainWnd->SetWindowText("My Title");
    >
    > -- Nand Kishore
    >
    > oLE wrote:
    >
    >>I've got a simple MFC program where I want to change the Window

    >
    > title.
    >
    >>At the moment i've got this bit of code:
    >>
    >> wndtitle = "Jobber - " + current.playername; // appends CString
    >> SendMessage(WM_SETTEXT);
    >>
    >>that changes the variable (wndtitle) and then sends this message

    >
    > which
    >
    >>sounds right and looks right because when i run it the window title

    >
    > is
    >
    >>eradicated. only thing is i don't know what function this message is
    >>calling so i can't put a SetWindowText(wndtitle) there.
    >>
    >>Thanks for any help,
    >>
    >>oLE

    >
    >


    I'm not using a document view architecture, sorry.

  5. Re: Update title in a CFrameWnd

    On Fri, 28 Jan 2005 09:57:42 +0000, oLE wrote:

    >I've got a simple MFC program where I want to change the Window title.
    >At the moment i've got this bit of code:
    >
    > wndtitle = "Jobber - " + current.playername; // appends CString
    > SendMessage(WM_SETTEXT);
    >
    >that changes the variable (wndtitle) and then sends this message which
    >sounds right and looks right because when i run it the window title is
    >eradicated. only thing is i don't know what function this message is
    >calling so i can't put a SetWindowText(wndtitle) there.
    >
    >Thanks for any help,
    >
    >oLE


    If you see that your WM_SETTEXT is making the title change but the title still
    doesn't have what you want, it makes me wonder if your CString is going out of
    scope after you make the SendMessage call.

    CFrameWnd has a member called "m_strTitle". Setting that variable in my prog
    (which is an SDI) makes the text appear on the title bar after the MFC
    framework's fields that they put on the title bar.

    HTH
    Dave

  6. Re: Update title in a CFrameWnd

    On Sat, 29 Jan 2005 16:12:19 -0800, Dave wrote:

    >it makes me wonder if your CString is going out of
    >scope after you make the SendMessage call.


    Oops my mistake. I think the scope problem will only happen if PostMessage is
    used, not SendMessage. Never Mind.

+ Reply to Thread