FIX: Mouse Hook Not Called When Used in User Controls (238672)
The information in this article applies to:
- Microsoft Visual Basic Learning Edition for Windows 6.0
- Microsoft Visual Basic Professional Edition for Windows 6.0
- Microsoft Visual Basic Enterprise Edition for Windows 6.0
This article was previously published under Q238672 SYMPTOMS
When you install a mouse hook to catch mouse events in a User Control module in Visual Basic, and then use the User Control module in a Standard EXE project, running the project in the IDE does not work the first time, but works as expected after that. However, running the project as a compiled EXE never works.
CAUSE
The User Control uses a mouse hook internally to display ToolTips. However, the mouse hook set by Visual Basic 6.0 does not call API CallNextHookEx most of the time. This results in all other mouse hooks at a later position in the hook chain not being called.
RESOLUTION
To work around the problem, you need to make sure that your mouse hook has an earlier position than the mouse hook in Visual Basic. One method to achieve this is to set your mouse hook after the User Control is loaded.
NOTE: Using hooks is not recommended and must be used with caution.
STATUSMicrosoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article. This bug was corrected in the latest service pack for Visual Studio 6.0. For additional information about Visual Studio service packs, click the following article numbers to view the articles in the Microsoft Knowledge Base: 194022 INFO: Visual Studio 6.0 Service Packs, What, Where, Why
194295 HOWTO: Tell That a Visual Studio Service Pack Is Installed To download the latest Visual Studio service pack, visit the following Microsoft Web site: REFERENCESFor additional information using hooks with UserControls, click the article number below
to view the article in the Microsoft Knowledge Base:
179398 HOWTO: Subclass a UserControl
Modification Type: | Minor | Last Reviewed: | 12/12/2005 |
---|
Keywords: | kbAPI kbBug kbCtrlCreate kbfix kbHook kbVS600sp4fix kbVS600sp5fix KB238672 |
---|
|