You need a character storage variable when you want to retrieve the text, not an uninitialised pointer variable!
TCHAR radiusValue[30];
GetWindowText(hwndradiusValue, radiusValue, _countof(radiusValue));
Question
I have to read data that is inserted into editable textfield in windows.
Just to test, I created following test code.
//Define variable and textfield
LPTSTR radiusValue;
HWND hwndradiusValue;
//Create Text Field. Note that, hWnd is handler to original window
hwndradiusValue=CreateWindowEx(WS_EX_WINDOWEDGE,TEXT("Edit"), TEXT(""), WS_CHILD | WS_VISIBLE, 10, 10, 50, 25, hWnd, NULL, NULL, NULL);
//Get Text from handle
GetWindowText(hwndradiusValue,radiusValue,30);
//Display the message
MessageBox(NULL, radiusValue, "TESTING", MB_OK);
I was expecting the Message to display the item in the textfield. But it did not. It displayed Null Charater. How can I solve this?
Solution
You need a character storage variable when you want to retrieve the text, not an uninitialised pointer variable!
TCHAR radiusValue[30];
GetWindowText(hwndradiusValue, radiusValue, _countof(radiusValue));