Hi! I'm a chemist new to coding and am working on a script to help me automatically process some of my data. The code I'm working on right now involves using WM_GETTEXT to grab the title of a window handle. However, right now the char buffer is only grabbing a single character, rather than the whole title. It looks like someone several years ago had a similar problem (link: http://www.cplusplus.com/forum/beginner/58207/), which indicates the issue is related to mixing data types. I tried switching to a TCHAR as suggested, but cannot compile on doing so. Here's the code I'm using:
1 2 3 4 5 6
int textLen = (int)SendMessage(windowHandle, WM_GETTEXTLENGTH, 0, 0);
std::cout << "The handle length is: " << textLen << std::endl;
constint bufferSize = 254;
char textBuffer[bufferSize] = "";
SendMessage(windowHandle, WM_GETTEXT, (WPARAM)bufferSize, (LPARAM)textBuffer);
std::cout << "The handle title is: " << textBuffer << std::endl;
Does anyone have any suggestions? I'm working in Microsoft Visual Studios if that makes a difference.