Visual Basic Development Bookmark and Share   
 Home > Visual Basic Interop and Upgrade > VB6 Form_KeyPress Event Not Firing When InteropControl has Focus
 

VB6 Form_KeyPress Event Not Firing When InteropControl has Focus

Repro Steps:

- Create a new InteropControl, add a TextBox, build the control
- Add the InteropControl to a VB6 Form
- Set the KeyPreview property of the Form to True
- Add a MsgBox or breakpoint to the Form_KeyPreview Event
- Run the project, type in the InteropControl (textbox). The KeyPreview Event is not raised.
- Repeat using a VB6 TextBox. The KeyPreview Event is raised.

(This can also be tested using a VB6 menu, the shortcuts do not work when the Interop Control has the focus. It is interesting that the acceleratorkeys work.)

PHL_09  Wednesday, November 25, 2009 4:53 PM
Hi PHL_09,

In this situation Interop Usercontrol handles this windows message alone, not let VB6 Form handle this message.

As far as I know, you have two options:

1. In WndProc function of Interop user control, you capture the keyboard message and use SendMessage to send keyboard messages to VB6 form to process first. Then let Inteop usercontrol handle this kind of messages.

2. You can define the events in Interop usercontrol for those unfired events required by VB6 form. Then handle these events in VB6 end to implement your requirement.

Please try this and feel free to post back when you have any further issues.


Best regards,
Riquel
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
Riquel_Dong  Monday, November 30, 2009 5:30 AM

You can use google to search for other answers

Custom Search

More Threads

• Late Binding: How NOT to use the default DOT.NET GetType method
• Using Stored Procedure (sp_send_dbmail) in VB6 error
• converting structure array to bytes
• Registration of .NET .dll not working?
• How can I Upgrade "Screen.MousePointer"?
• UserControls and the Load method.
• Error code BC30691
• Docked control on usercontrol does not resize.
• My Program not run !
• changing button array length