-
May 2nd, 2003, 01:07 PM
#1
KEYUP and KEYDOWN EVENT
Please, i need help!!
I have an MFC dialog based application, it has a dialog with some edit controls, i need to know when the user press an "enter key" or an "arrow up" or an "arrow down" in a specific edit control. I suposse i have to use the OnKeyUp event, but I don´t know how to do it, when i search this message in the classwizard i didn't find it
Does anybody have an example?
I hope you understand my english, thanks anyway!!
Saludos
Aida
-
May 2nd, 2003, 01:17 PM
#2
You can 1) subclass the edit control or 2) use PreTranslateMessage to capture the keypress.
PHP Code:
BOOL CWinCvtDlg::PreTranslateMessage(MSG *pMsg)
{
/*++
If delete key is hit, and the window
that has focus is the is the listctrl,
call the default delete item function
--*/
if(pMsg->message == WM_KEYDOWN && pMsg->wParam == VK_DELETE && pMsg->hwnd == m_FileListCtrl.GetSafeHwnd())
{
OnBtnRemove();
return TRUE; // handled...
}
return CDialog::PreTranslateMessage(pMsg);
}
That's a function I wrote a bit back, figured it might help. It caputres key down and sees if the window that received the press was the same window as my list ctrl, and if it was it triggered the OnBtnRemoved function, otherwise it let the CDialog do as it needed
-
May 2nd, 2003, 01:21 PM
#3
Take a look at this FAQ for further information on the topic...
-
May 7th, 2003, 02:46 PM
#4
Thanks a lot! That really works
-
May 8th, 2003, 01:24 AM
#5
What works? PreTranslateMessage? MFC experts don't use it because they know easier ways to do it. See the CodeGuru article for the solutions used by MFC experts.
-
May 8th, 2003, 08:55 AM
#6
?
Hi!
Dou you mean that i shouldn't use Pretranslate messages???
Why?
Dou yo have the link for the article that you mentioned???
TKS
-
May 8th, 2003, 09:15 AM
#7
Yeah there is a better way of doing the OK button, described in the FAQ that Andreas posted to you earlier. It works, yes, but it's not a real good way of doing it for your case.
http://www.codeguru.com/forum/showth...hreadid=231075
-
May 8th, 2003, 09:40 AM
#8
Re: ?
Originally posted by amoyao
Dou yo have the link for the article that you mentioned???
Look at the link at the bottom of the FAQ item that Andreas posted and that Eli reposted; the part just before "written by Sam Hobbs".
-
December 21st, 2008, 11:20 PM
#9
Re: KEYUP and KEYDOWN EVENT
Hello Everyone,
Im developing an application in Win32. In this I have used a Custom dialog box with some buttons on it and would like to shift the focus on these based on the navigation keys from the keyboard.
Here is the problem Im not able to catch the key down event inside the dialog box. I would appriciate some help on this.
Thanks.
-
December 21st, 2008, 11:37 PM
#10
Re: KEYUP and KEYDOWN EVENT
Originally Posted by Win32_developer
Hello Everyone,
Im developing an application in Win32. In this I have used a Custom dialog box with some buttons on it and would like to shift the focus on these based on the navigation keys from the keyboard.
Here is the problem Im not able to catch the key down event inside the dialog box. I would appriciate some help on this.
Thanks.
Why are you hijacking a 5 year old thread....Have YOU been working on theis SPECIFIC problem for the last five years????
Ask a moderator to plit your post off to a new thread, then wait for them to do so......
TheCPUWizard is a registered trademark, all rights reserved. (If this post was helpful, please RATE it!)
2008, 2009,2010
In theory, there is no difference between theory and practice; in practice there is.
* Join the fight, refuse to respond to posts that contain code outside of [code] ... [/code] tags. See here for instructions
* How NOT to post a question here
* Of course you read this carefully before you posted
* Need homework help? Read this first
-
January 14th, 2009, 03:41 PM
#11
Re: KEYUP and KEYDOWN EVENT
I know that this latest couple of replies are nearly a month old but I have been trying since September to sign in to CodeGuru and I was unsuccessful until now.
Originally Posted by TheCPUWizard
Why are you hijacking a 5 year old thread....Have YOU been working on theis SPECIFIC problem for the last five years????
Note that this was the first and only post by the person; I think you scared them off.
Originally Posted by TheCPUWizard
Ask a moderator to plit your post off to a new thread, then wait for them to do so......
Or the person could create a new thread. They could post a message here when they do, so that everyone knows to answer that thread.
Or you could suggest the person read Processing Keyboard Messages.
Last edited by Sam Hobbs; January 14th, 2009 at 03:43 PM.
Reason: syntactical clarification
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|