Displays text using DrawText after loading it from a file
Hello, I am trying to display the text in win32 console window using DrawText after loading the string lines from a text file.
Here's the code for the file loading:
Code:
std::vector<basic_string<TCHAR>> vectorLine;
wfstream file ;
basic_string<TCHAR> line;
vectorLine.clear();
wcscpy(fileName,_fileName);
file.open("data/data_test.txt");
if (!file) {
printf("Error: TokenManager: invalid file");
}
while( getline(file, line)) {
vectorLine.push_back(line);
}
//Next, I draw the text from the lines stored in a vector.
basic_string<TCHAR> tempString;
for (int i=0; i < tokenManager.vectorLine.size(); i++) {
tempString=tokenManager.vectorLine[i].c_str()
DrawText(hdc, tempString, -1,&rectTextLine,DT_SINGLELINE | DT_LEFT | DT_VCENTER);
}
The error is DrawText does not accept basic_string<TCHAR> and needs a long pointer to a string. This is where I am confused. I tried changing basic_string<TCHAR> to std::string and std::wstring but to no avail.
Hope someone can help recommend me the change. It's either how I delcare the vectorLine or add some macros for the conversion.