Editbox identification problem
-
Hi All, I've created a dialog based application with the dialog having multiple editboxes. What I want to achieve is to call a specific function when I press "Enter" key. Each editbox should trigger its specific function or I should be able to know from which editbox the enter key was pressed. Please help. Thanks, Gajendra
-
Hi All, I've created a dialog based application with the dialog having multiple editboxes. What I want to achieve is to call a specific function when I press "Enter" key. Each editbox should trigger its specific function or I should be able to know from which editbox the enter key was pressed. Please help. Thanks, Gajendra
gajendrakashyap wrote:
Each editbox should trigger its specific function or I should be able to know from which editbox the enter key was pressed.
You GetFocus api to get currently focussed Edit box!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers, Alok Gupta VC Forum Q&A :- I/ IV Support CRY- Child Relief And You
-
gajendrakashyap wrote:
Each editbox should trigger its specific function or I should be able to know from which editbox the enter key was pressed.
You GetFocus api to get currently focussed Edit box!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers, Alok Gupta VC Forum Q&A :- I/ IV Support CRY- Child Relief And You
Using this I can get a pointer to the ebox. If I could get the ID number of the ebox in context, it would help me more than having a pointer as my application logic depends on that. Can you suggest something on obtaining focussed ebox control id number? Thanks, Gajendra
-
gajendrakashyap wrote:
Each editbox should trigger its specific function or I should be able to know from which editbox the enter key was pressed.
You GetFocus api to get currently focussed Edit box!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers, Alok Gupta VC Forum Q&A :- I/ IV Support CRY- Child Relief And You
Using this I can get a pointer to the ebox. If I could get the ID number of the ebox in context, it would help me more than having a pointer as my application logic depends on that. Can you suggest something on obtaining focussed ebox control id number?
-
Using this I can get a pointer to the ebox. If I could get the ID number of the ebox in context, it would help me more than having a pointer as my application logic depends on that. Can you suggest something on obtaining focussed ebox control id number?
You can override default PreTranslateMessage function of the dialog/window class. BOOL CBAMBuildToolDlg::PreTranslateMessage(MSG* pMsg) { if (pMsg->message == WM_KEYDOWN) { if(pMsg->wParam == VK_RETURN) { if (pMsg->hwnd == ::GetDlgItem(*this, IDC_EDITBOXID) //Replace with proper ID { //Handling of the return key for this edit box return TRUE; } } } return CDialog::PreTranslateMessage(pMsg); } I hope the above code snippet will help you. Regards, Stanly
-
Using this I can get a pointer to the ebox. If I could get the ID number of the ebox in context, it would help me more than having a pointer as my application logic depends on that. Can you suggest something on obtaining focussed ebox control id number?
gajendrakashyap wrote:
Can you suggest something on obtaining focussed ebox control id number?
when you got pointer to Window you can easily call function GetDlgCtrlID to retrieve it control id
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers, Alok Gupta VC Forum Q&A :- I/ IV Support CRY- Child Relief And You
-
You can override default PreTranslateMessage function of the dialog/window class. BOOL CBAMBuildToolDlg::PreTranslateMessage(MSG* pMsg) { if (pMsg->message == WM_KEYDOWN) { if(pMsg->wParam == VK_RETURN) { if (pMsg->hwnd == ::GetDlgItem(*this, IDC_EDITBOXID) //Replace with proper ID { //Handling of the return key for this edit box return TRUE; } } } return CDialog::PreTranslateMessage(pMsg); } I hope the above code snippet will help you. Regards, Stanly
stanlymt wrote:
IDC_EDITBOXID)
from where this ID will come.. and are you going to check like this, for every Control present on Dilaog box.. this really going to make you PreTranslateMessage Bulky..
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers, Alok Gupta VC Forum Q&A :- I/ IV Support CRY- Child Relief And You
-
stanlymt wrote:
IDC_EDITBOXID)
from where this ID will come.. and are you going to check like this, for every Control present on Dilaog box.. this really going to make you PreTranslateMessage Bulky..
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers, Alok Gupta VC Forum Q&A :- I/ IV Support CRY- Child Relief And You
-
gajendrakashyap wrote:
Can you suggest something on obtaining focussed ebox control id number?
when you got pointer to Window you can easily call function GetDlgCtrlID to retrieve it control id
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers, Alok Gupta VC Forum Q&A :- I/ IV Support CRY- Child Relief And You
Thanks Alok. Actually i tried that, but misspelt the name of function :( I could work from your first clue itself. Thanks for the help !! :) Thanks & regards, Gajendra
-
ID is the Editbox ID in the resource file. If you need to handle differently for each edit box in the dialog, you have to handle it seperately. Otherwise, you can use one button as 'default' button and handle the event there.
stanlymt wrote:
you can use one button as 'default' button and handle the event there.
then I believe his question wrong.. actually that person want currently focused EditBox at the Time of press of enter key
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers, Alok Gupta VC Forum Q&A :- I/ IV Support CRY- Child Relief And You