-
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?
-
string concentration
strcat ("Notepad",&chosenfile)
should do it, i think.
-
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());
-
-
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""
-
Code:
#include <string>
using std::string;
Just use chosenfile then :)