PRB: Form's KeyPress Is Not Fired When ActiveX Control Has Focus
Article ID: 200266
Article Last Modified on 5/12/2003
APPLIES TO
- Microsoft Visual FoxPro 3.0 Standard Edition
- Microsoft Visual FoxPro 3.0b Standard Edition
- Microsoft Visual FoxPro 5.0 Standard Edition
- Microsoft Visual FoxPro 5.0a
- Microsoft Visual FoxPro 6.0 Professional Edition
- Microsoft Visual FoxPro 7.0 Professional Edition
This article was previously published under Q200266
SYMPTOMS
You have a form with code in the KeyPress event and the KeyPreview property is set to true (.T.). When an ActiveX control has focus, the KeyPress event of the form does not fire.
CAUSE
The KeyPress event for many ActiveX controls happens to have the same name as the Visual FoxPro native KeyPress event. ActiveX controls on Visual FoxPro forms also have their own window. As a result, they handle the KeyPress event independently of Visual FoxPro.
RESOLUTION
In the KeyPress of the ActiveX control, add the following code as the first line of the event:
ThisForm.KeyPress
STATUS
This behavior is by design.
Keywords: kbbug kbnofix kbcodesnippet kbprb kbctrl KB200266