Problem in capturing the enter event of an edit control.
-
hai friends. how to capture the enter key event of an edit control? for example, user will type some data in the edit control and hits enter key. then i have to do some validations and auto correct it. iam able to get the enter event in the pretranslate message. but i want the nid here. though comparing pMsg->hwnd will do, it is not applicable for my dialog because, there are as many as 200 controls with me. any ideas please? thank you.
-
hai friends. how to capture the enter key event of an edit control? for example, user will type some data in the edit control and hits enter key. then i have to do some validations and auto correct it. iam able to get the enter event in the pretranslate message. but i want the nid here. though comparing pMsg->hwnd will do, it is not applicable for my dialog because, there are as many as 200 controls with me. any ideas please? thank you.
Hello Chandu, You can identify whether the handle is that of an edit control by getting the class name. Please go throught the code below.
TCHAR strClassName[255]; CString csEditBoxClassName( _T("Edit")); // Get Class name of the wnd from handle. ::GetClassName( pMsg->hwnd, strClassName, 255 ); if( 0 == csEditBoxClassName.CompareNoCase( strClassName )) { // Yes. Its an edit control. // TODO: Do your stuffs here. }
I can give you one more hint. Since you have 200 controls, i guess you have created those controls dynamically by providing a range of control ids. If thats the case, you can use the resource id to identify whether its an edit control. For getting the resource id from handle,UINT nResourceId = GetWindowLong( pMsg->hwnd, GWL_ID );
If you still have problems or if this is not what you needs, let me know. :) Regards, Jijo.________________________________ Yesterday is history, Tomorrow is a mystery, But today is a present.