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.
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.
Hi. you should have to draw the controls (Edit, Button etc..) in the WM_CREATE message handling section of main Parent Window. So, the controls will be drawn right after when the main window is drawn.
So, you will get the hWnd handle of all controls from inside the Message Callback thread.
Anotherway is, decalring the hWnd variables of controls as Global variables.. but its a bad idea.
You not need to declare every controls handle in the window as global. So, i think the first one will be better for you.
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
Bookmarks