Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

using GetWindowText()

Status
Not open for further replies.

oaquao

Programmer
May 16, 2001
12
US
I'am trying to retrieve the text from an edit box.
long WINAPI MainWndProc(HWND hWnd,UINT msg,WPARAM wParam,
LPARAM lParam){
HWND hwndCtl=(HWND) lParam;
int nMaxCount=30;
char* str;
switch (msg)
{
case WM_GETTEXT:
if (hwndCtl==hWndEditQues1) GetWindowText(hWndEditQues1,str,nMaxCount);
case WM_DESTROY:
PostQuitMessage(0);
return 0;
default:
return DefWindowProc(hWnd,msg,wParam,lParam);
}
Just started VC++ the book I'am using had a some code using Windows API but not much, used the search function and MSDN wasn't that helpful any help or a link to a tutorial would be apprecitated.
Thanks
 
It's a little unclear what you're trying to do here. Edit boxes are typically used in dialogs, and what you have looks more like a normal window. Also, WM_GETTEXT is received by the Edit control, and it may receive it because of a call to GetWindowText(). This code might be of some value if your Window was target of GetWindowText(), in which case you'd return whatever value was appropriate, and not issue GetWindowText() yourself, unless maybe you're subclassing a textbox control.

The following might be code in a dialogbox procedure for handling a request for the value in an edit box (response to clicking BUTTON1):

switch (msg)
{
.....
case WM_COMMAND:

int Id = LOWORD(wParam);
switch (Id)
{
.....
case IDC_BUTTON1:
char buff[256];
HWND hWndEdit1 = GetDlgItem(hDlg,IDC_EDIT1);
GetWindowText(hWndEdit1,buff,256);
return TRUE;
.....
}
}
:) I just can't help it, I like MS...:)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top