-
April 16th, 2010, 10:32 AM
#1
Get text from textbox
Does anyone know how to get text from a text box with out it displaying odd symbols with chars?
Thanks
I need to get the text but everything online keeps telling me to use GetWindowText which needs a char which ends up with odd symbols in it such as a smiley face and stuff.
I need to get the text as a string not a char.
Thanks again
-
April 16th, 2010, 11:47 AM
#2
Re: Get text from textbox
GetWindowText which needs a char
Code:
int GetWindowText(
__in HWND hWnd,
__out LPTSTR lpString,
__in int nMaxCount
);
I guess I'm not understanding what you wrote as I don't see where the GetWindowText() function needs a char? Might you be having some kind of UNICODE problems?
-
April 16th, 2010, 12:06 PM
#3
Re: Get text from textbox
Code:
void GetTextAndDoSomething(HWND hWnd)
{
// get the length of the text
const int nTextLength = ::GetWindowTextLength(hWnd);
// allocate a buffer for the text
char * pData = new char[nTextLength + 1];
// Get the text
::GetWindowTextA(hWnd,pData,nTextLength + 1);
// Do something with this text
::MessageBoxA(0,pData,"This is the text!",MB_OK);
// free the buffer
delete [] pData;
}
-
April 16th, 2010, 12:32 PM
#4
Re: Get text from textbox
thanks you two you helped me out
thanks again!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|