Results 1 to 6 of 6

Thread: Adding two values!

  1. #1

    Thread Starter
    PowerPoster abdul's Avatar
    Join Date
    Dec 2000
    Location
    Ontario,Canada
    Posts
    2,827

    Adding two values!

    I want to set my window's titlebar text to "the name of my program" and the opened file name:

    Here are the variables:

    char chosenfile[MAX_PATH];

    That variable contains the name of the file opened.
    Now I want to set the window's text to:

    SetWindowText(hwnd, "Notepad" + chosenfile);

    but that method does not work. What is the way to add two string and then set the text to that string?
    Baaaaaaaaah

  2. #2
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221

    string concentration

    strcat ("Notepad",&chosenfile)
    should do it, i think.
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  3. #3
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    No. A literal string is always const char*. The string class is about as easy as it gets:
    Code:
    SetWindowText(hWnd, (string("Notepad - ") + pcFileName).c_str());
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  4. #4
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    oh ok, i wont argue
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  5. #5

    Thread Starter
    PowerPoster abdul's Avatar
    Join Date
    Dec 2000
    Location
    Ontario,Canada
    Posts
    2,827
    But how do I set the text. That code does not work because I have the variable "chosenfile" instead of "pcFileName". And also it gives me error message saying that "string" is not declared even I include the header "<string.h>" OR ""string.h"" OR ""string""
    Baaaaaaaaah

  6. #6
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    Code:
    #include <string>
    
    using std::string;
    Just use chosenfile then
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

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