Print Page | Close Window

WM_KEYUP not handled in Property Grid Edits

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Property Grid
Forum Description: Topics Related to Codejock Property Grid
URL: http://forum.codejock.com/forum_posts.asp?TID=12325
Printed Date: 30 November 2024 at 10:05am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: WM_KEYUP not handled in Property Grid Edits
Posted By: dbrulhart
Subject: WM_KEYUP not handled in Property Grid Edits
Date 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



Replies:
Posted By: Oleg
Date Posted: 06 October 2008 at 2:37am
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


Posted By: dbrulhart
Date Posted: 06 October 2008 at 5:04am
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


Posted By: Oleg
Date Posted: 06 October 2008 at 8:59am
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


Posted By: dbrulhart
Date Posted: 06 October 2008 at 10:17am
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


Posted By: Oleg
Date Posted: 07 October 2008 at 2:37am
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


Posted By: dbrulhart
Date Posted: 07 October 2008 at 2:44am
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


Posted By: Oleg
Date Posted: 07 October 2008 at 9:54am
Yes.

-------------
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net