MFC related problem
-
hey all! i am an amateur in VC++! i ve got a problem and that is by pressing Enter Key of keyboard, my program shuts down as i guess its by default! Now my program uses a text box and what i want is is when i write something and press Enter! the Enter key activate an Event Handler! or a specified function say displaying the text what is written in the text box in other list box etc! plzz anyone who can help in this regard! also is there any way to creat my own event handler???? Like for Enter key? as there is one for helpinfo with WM_HELPINFO which activates if F1 is pressed! I ll be grateful if anyone lead me to the solution! whats wrong wit'cha?
-
hey all! i am an amateur in VC++! i ve got a problem and that is by pressing Enter Key of keyboard, my program shuts down as i guess its by default! Now my program uses a text box and what i want is is when i write something and press Enter! the Enter key activate an Event Handler! or a specified function say displaying the text what is written in the text box in other list box etc! plzz anyone who can help in this regard! also is there any way to creat my own event handler???? Like for Enter key? as there is one for helpinfo with WM_HELPINFO which activates if F1 is pressed! I ll be grateful if anyone lead me to the solution! whats wrong wit'cha?
In a Dialog box the enter key causes the OnOK method to get called. There are a couple of ways you can do this, you can do your processing in OnOK but not call CDialog::OnOK, and to make the OK button work again, you will need to add an event handler for the ok button and in there call CDialog::OnOK. Or you can catch the WM_KEYDOWN message for the VK_ENTER key in PreTranslateMessage and do your processing there, but don't call CDialog::PreTranslateMessage when the enter key is pressed.
AliR. Visual C++ MVP
-
hey all! i am an amateur in VC++! i ve got a problem and that is by pressing Enter Key of keyboard, my program shuts down as i guess its by default! Now my program uses a text box and what i want is is when i write something and press Enter! the Enter key activate an Event Handler! or a specified function say displaying the text what is written in the text box in other list box etc! plzz anyone who can help in this regard! also is there any way to creat my own event handler???? Like for Enter key? as there is one for helpinfo with WM_HELPINFO which activates if F1 is pressed! I ll be grateful if anyone lead me to the solution! whats wrong wit'cha?
-
In a Dialog box the enter key causes the OnOK method to get called. There are a couple of ways you can do this, you can do your processing in OnOK but not call CDialog::OnOK, and to make the OK button work again, you will need to add an event handler for the ok button and in there call CDialog::OnOK. Or you can catch the WM_KEYDOWN message for the VK_ENTER key in PreTranslateMessage and do your processing there, but don't call CDialog::PreTranslateMessage when the enter key is pressed.
AliR. Visual C++ MVP
well i didn get ya ! wat i wanna do is to use tht Enter key for activating any of my desired button! Like say a button Send! if i write something in the text box and press Enter! it works if i ve CLICKED Send! i ll be grateful if u clearify it a bit!
-
well thnxx david! but see this! switch (nChar) { case VK_RETURN: OnBsend(); } so if VK_RETURN is the case then call OnBsend() function! am i right? but if now i press Enter ! then still the program closes!!? please reflect light on tht
-
well thnxx david! but see this! switch (nChar) { case VK_RETURN: OnBsend(); } so if VK_RETURN is the case then call OnBsend() function! am i right? but if now i press Enter ! then still the program closes!!? please reflect light on tht
What is happening in the
OnOK()
handler()?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
-
What is happening in the
OnOK()
handler()?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
well i havent used OnOK() Handler! and truelly speakin i dunno well abt tht! i do know tht Enter key initiate the OnOK() handler and so the program closes! but how to remove this property from enter key? u know clicking Send Button while working in a TextBox is cumbersome! just like chat in msn messenger or yahoo ones window! where when we press Enter! or wat u call RETURN the message is sent or we can say tht Send button is activated!
-
well i havent used OnOK() Handler! and truelly speakin i dunno well abt tht! i do know tht Enter key initiate the OnOK() handler and so the program closes! but how to remove this property from enter key? u know clicking Send Button while working in a TextBox is cumbersome! just like chat in msn messenger or yahoo ones window! where when we press Enter! or wat u call RETURN the message is sent or we can say tht Send button is activated!
ddspliting wrote:
well i havent used OnOK() Handler! and truelly speakin i dunno well abt tht! i do know tht Enter key initiate the OnOK() handler and so the program closes! but how to remove this property from enter key?
So did you bother to read this?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
-
ddspliting wrote:
well i havent used OnOK() Handler! and truelly speakin i dunno well abt tht! i do know tht Enter key initiate the OnOK() handler and so the program closes! but how to remove this property from enter key?
So did you bother to read this?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
-
Read? What programmers read? Pfffffffft we "write" .... code. We don't need no stinkin readin
:sigh:
Mark Salsbery Microsoft MVP - Visual C++ :java:
-
ddspliting wrote:
well i havent used OnOK() Handler! and truelly speakin i dunno well abt tht! i do know tht Enter key initiate the OnOK() handler and so the program closes! but how to remove this property from enter key?
So did you bother to read this?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
Sorry! I read tht a bit late! and my problem is solved now! thanxx to u David and to the codeproject! Really Nice Service! top that! :)