April 9th, 2009, 08:07 AM
Hello and first sorry for my very bad english.
i have little knowledge about c and c++ but im trying to learn win32 programming with c++. its little hard and im very new at that. im trying to do very very simple thing: i have an main window, 1 button, 1 edit control. when user clicks button, i wanna show edit controls text with messagebox. there is a problem, i guess i should get text from editcontrol with gettext api, but i have to pass hwnd for that. actually im already have hwnd when i calling createwindowex function, but its not public. so in message switch block i dont have hwnd for edit control. what should i do? findwindow? or maybe public variable? Thanks.
April 9th, 2009, 09:23 AM
Re: Gettext ?
Perhaps, you know the control ID of this editr control?
Then you could use GetDlgItemText API.
April 24th, 2009, 01:54 AM
April 24th, 2009, 09:38 AM
Re: Gettext ?
As Victor already suggested, if you know the parent handle (you know it in the parent window procedure) and the identifier of the control (you know it as the value passed in hMenu parameter of CreateWindow(Ex) function or as a resource ID), then
- you can call GetDlgItemText to directly get its text;
- you can call GetDlgItem to get its handle to be used in other function calls.
So, you don't need to keep the control handles as global variables, as class members, or in any other place.
Click Here to Expand Forum to Full Width