OnKeydown for “-” does not get fired in Delphi 7 application

被刻印的时光 ゝ 提交于 2019-12-20 06:32:56

问题


We are using Delphi 7 enterprise edition, application is build on windows XP, testing on both Windows XP and Windows 7.

In an application we maintain, something strange is happening. For some reason hitting the "-" key (qwerty layout, between "0" and "=" keys on top) does not register at all.

We checked in the OnKeyDown of the edit we found it with, the OnKeyDown of the form (with and without key preview) and even the ProcessMessage routine, but the event for this key never reaches the application. We get the same results for OnKeyPress.

Yes, the "-" key on the numpad DOES work. Also, this behavior is only seen in this application, but if we create a new application with only the OnKeyDown of the default form in unit1.pas implemented. it does work.

So somehow we managed to tell the application to properly ignore this one key. Does anyone have an idea how this could be (un)done?


回答1:


David's comment is on the right track; You can (with version control) strip back the app until you understand what is going on. However I think that you need to understand the following concepts as well:

  1. OnKeyDown event in a form is not the only place that keyboard shortcuts could go. You should find out where else it's going to, which is why Sertac's comment is there.

  2. It is possible that something OUTSIDE your application is trapping that keyboard key (although this is more common with Control or Alt + Key combinations).

  3. It is possible that something inside your form, or elsewhere in your application is grabbing that key and consuming it.

  4. There is a good article here about KeyPreview, you need to understand that too.



来源:https://stackoverflow.com/questions/10449271/onkeydown-for-does-not-get-fired-in-delphi-7-application

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!