TCHAR* GetButtonState(HWND hWnd, GamePosition butonPosition){
// Create String Buffer for populating Button text
TCHAR wndwTxt[5];
// Retrieve Button text and store in Buffer
GetDlgItemText(hWnd, GetDlgCtrlID((HWND)buttonList[butonPosition]), wndwTxt, 5);
return wndwTxt;
}
Now, if I debug and go into the GetButtonState function, the text is being populated correctly. Even if I do a Watch on GetButtonState - I'll get the correct value.
However the Messagebox is showing random characters?
Having said that I'm not sure if this could be a Win32 API issue with character encoding?
The array is a local variable and is therefore destroyed once you leave the functions scope, so you should try using dynamically allocated memory instead