CreateWindow "EDIT" class child windows
hi, i''m just learning the winAPI, and i''m writing a text editor a la notepad. now, i''ve created the edit window with the following code:
switch(Message)
{
case WM_CREATE:
CreateWindowEx(0, "EDIT", "", WS_CHILD | WS_VISIBLE |
WS_VSCROLL | WS_HSCROLL | ES_MULTILINE |
ES_WANTRETURN | ES_AUTOVSCROLL, CW_USEDEFAULT,
CW_USEDEFAULT, CW_USEDEFAULT,
CW_USEDEFAULT, hwnd, (HMENU) IDC_MAIN_TEXT, g_hInst,
NULL);
SendDlgItemMessage(hwnd, IDC_MAIN_TEXT, WM_SETFONT,
(WPARAM) GetStockObject(DEFAULT_GUI_FONT),
MAKELPARAM(TRUE, 0));
break;
now, my question is: how do i know if the window is being edited? is there a message i could use? do i need to write a handler for that window?
thanks,
johan.
Johan Venterjventer@writeme.com
Edit controls send an EN_UPDATE and an EN_CHANGE message when text is entered into them. You might want to handle these messages in order to achieve what you''re trying to do.
EN_UPDATE & EN_CHANGE are received via the WM_COMMAND message. They are in the HI order of the WPARAM parameter. This is basically what you need to do.
switch(uMsg)
{
case WM_COMMAND:
if(HIWORD(wParam) == EN_UPDATE)
{
do your stuff here
}break;
}
Hope that helped.
EN_UPDATE & EN_CHANGE are received via the WM_COMMAND message. They are in the HI order of the WPARAM parameter. This is basically what you need to do.
switch(uMsg)
{
case WM_COMMAND:
if(HIWORD(wParam) == EN_UPDATE)
{
do your stuff here
}break;
}
Hope that helped.
==========================================In a team, you either lead, follow or GET OUT OF THE WAY.
if you''re just interested in getting and setting the text then you can use SetDlgItemText(), GetDlgItemText() and GetWindowTextLength()
NuffSaid: That''s exactly what I wanted to know, but wnd handler do I put that in? In my main (parent) handler? Or do I need a handler for the edit window?
Johan Venterjventer@writeme.com
I think I answered my own question, I put the EN_CHANGE check in my main window handler and it seems to work...was I correct in doing this?
Johan Venterjventer@writeme.com
You handle the WM_COMMAND in the Callback function(message handler) of the parent window of the edit control. I hope that was clear That''s te best I can do at the moment.
The edit control is fairly self contained. You don''t need to write a callback function for it. It sort of handles itself.
The edit control is fairly self contained. You don''t need to write a callback function for it. It sort of handles itself.
==========================================In a team, you either lead, follow or GET OUT OF THE WAY.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement