How to get/set text of a textbox in VC++ ?

Apr 4, 2011 at 9:55am
I have created a textbox in VC++ using following code. ..

HWND ehnd = CreateWindow(TEXT("edit"), TEXT("Enter your text here"),
WS_VISIBLE |WS_CHILD,
50,50,480,300,
hwnd, (HMENU) 3,NULL,NULL);


now I want to get/set the text in the textbox.... please help me out of this...


Thanks in advance,,
Last edited on Apr 4, 2011 at 11:35am
Apr 4, 2011 at 12:00pm
GetWindowText and SetWindowText functions
Apr 4, 2011 at 4:56pm
Get the text:

1
2
3
4
5
6
7
8
9
10
//Get window text into a std::string.
std::string GetWindowText (HWND hWnd)
{
	int iLength = (GetWindowTextLength (hWnd) + 1);
	char *cpText = new char [iLength];
	::GetWindowText (hWnd, cpText, iLength);
	string sReturnString = cpText;
	delete [] cpText;
	return sReturnString;
}


Set the text:

http://msdn.microsoft.com/en-us/library/ms633546%28v=vs.85%29.aspx
Apr 6, 2011 at 4:45am
thanks . . .. .
Topic archived. No new replies allowed.