WM_KEYUP not handled in Property Grid Edits |
Post Reply |
Author | |
dbrulhart
Groupie Joined: 19 October 2006 Location: Switzerland Status: Offline Points: 38 |
Post Options
Thanks(0)
Posted: 03 October 2008 at 11:58am |
Hi Oleg/All,
I've a problem with Property Grid Edits: If I type a number in a Property Grid Edit Item with the numeric keypad then both WM_KEYDOWN and WM_KEYUP are caught by the Edit and all is fine. But if I type a number with the alphanumeric side of the keyboard (1/!, 2/@, 3/#, etc...) then only the WM_KEYDOWN is caught and the WM_KEYUP is still generated and then caught by my CWinApp::PreTranslateMessage(), which purposely generates some action that have the consequence of loosing the focus of the Edit box. Is this a bug ? Or a intended feature ? And if yes can this be disabled ? Thanks for shedding some lights here. Best regards, Dominique |
|
Oleg
Admin Group Joined: 21 May 2003 Location: United States Status: Offline Points: 11234 |
Post Options
Thanks(0)
|
Hi,
Have to be something in your code. PreTranslateMessage doesn't eat keys. Check what methods you override and what code can be reason.
|
|
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS |
|
dbrulhart
Groupie Joined: 19 October 2006 Location: Switzerland Status: Offline Points: 38 |
Post Options
Thanks(0)
|
Hi Oleg,
Well, after deeper search it appears that there's indeed no difference between Alpha Numbers and Numpad Numbers... ... both generate a WM_KEYUP... and this is a problem for us as our Accelerators mechanism deals with KeyDown and KeyUp separately. All our custom controls that should prevent Accelerators to be triggered do implement a PreTranslateMessage() like this: ///////////////////////////////////////////////////////////////////////////// BOOL CItemEdit::PreTranslateMessage(MSG *pMsg) { // To bypass ExAccelerators if (pMsg->message == WM_KEYDOWN || pMsg->message == WM_KEYUP) { TranslateMessage(pMsg); DispatchMessage(pMsg); return TRUE; } return CRichEditCtrl::PreTranslateMessage(pMsg); } This makes sure that when this Edit Box has the focus no WM_KEYDOWN AND WM_KEYUP are caught by the CWinApp::PreTranslateMessage(). Is there any way we can do the same in your code... without recompiling it or making a special version ? At this point, this makes our app almost unusable... Thanks for your help. Dominique |
|
Oleg
Admin Group Joined: 21 May 2003 Location: United States Status: Offline Points: 11234 |
Post Options
Thanks(0)
|
Hi,
I still not sure what you have in your code and why it doesn't work for you, so can't suggest something :(
If you attach some sample that show prolem we will find some solution :)
|
|
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS |
|
dbrulhart
Groupie Joined: 19 October 2006 Location: Switzerland Status: Offline Points: 38 |
Post Options
Thanks(0)
|
Hi Oleg,
It's quite simple, we have some code in CWinApp::PreTranslateMessage that triggers events for WM_KEYDOWN and WM_KEYUP. These events should not be triggered when any Edit Box has the focus and for this any Edit Box should catch WM_KEYDOWN and WM_KEYUP. We do this by overriding PreTranslateMessage for all our Edit Box. (Please see the code in my previous post). The problem is that Items in your PropertyGrid catch the WM_KEYDOWN but not the WM_KEYUP when typing in them so all WM_KEYUP are then caught by our CWinApp::PreTranslateMessage. So the question is: Is there a way for your controls to catch WM_KEYUP as well, so we don't have to override all your controls PreTranslateMessage to do the same as our ? Thanks in advance Dominique |
|
Oleg
Admin Group Joined: 21 May 2003 Location: United States Status: Offline Points: 11234 |
Post Options
Thanks(0)
|
Don't you think its easy to change code of your PreTranslateMessage than all Edit box that you can have ??
:)
Some hints:
TCHAR szClass[10];
CWnd* pWndFocus = GetFocus(); if (IsChild(pWndFocus) && GetClassName(pWndFocus->m_hWnd, szClass, 10) && (lstrcmpi(szClass, _T("EDIT")) == 0)) { return TRUE; } |
|
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS |
|
dbrulhart
Groupie Joined: 19 October 2006 Location: Switzerland Status: Offline Points: 38 |
Post Options
Thanks(0)
|
Hi Oleg,
Thanks for the suggestion. It wouldn't work for our controls as they're not all Edits, we have various other kind of windows, controls, popups, etc... that have to eventually catch the key messages (or not) depending their own status and context... that the main CWinApp::PreTranslateMessage() doesn't know anything about. But that may work for you Edits. Are all items having key input in a property grid of class EDIT ? Thanks again Dominique |
|
Oleg
Admin Group Joined: 21 May 2003 Location: United States Status: Offline Points: 11234 |
Post Options
Thanks(0)
|
Yes.
|
|
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS |
|
Post Reply | |
Tweet
|
Forum Jump | Forum Permissions You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |