CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Apr 2008
    Posts
    9

    Changing the window title

    Hey.

    Basically im trying to update the window title for my program.

    At the moment im using setWindowTitle to do this, but I can't figure out how to include an int variable to display properly.

    I have an integer for 'lives' and setting the title to something like "setWindowTitle("Lives: " + lives); produces strange errors.

    Anyone able to help?

  2. #2
    Join Date
    Aug 2005
    Location
    LI, NY
    Posts
    576

    Re: Changing the window title

    You can't add an integer to a string in C++ (assuming you don't overload operator+ for that purpose). Use stringstreams:

    Code:
    #include <sstream>
    
    // ...
    
    std::ostringstream oss;
    oss << "Lives: " << lives;
    setWindowTitle(oss.str().c_str()); // Assuming setWindowTitle takes a C-style string
    - Alon

  3. #3
    Join Date
    Apr 2008
    Posts
    9

    Re: Changing the window title

    Thanks heaps, that really helped

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