How To Prevent the ENTER Key From Firing in TreeView Control (216664)
The information in this article applies to:
- Microsoft Visual Basic Learning Edition for Windows 5.0
- Microsoft Visual Basic Learning Edition for Windows 6.0
- Microsoft Visual Basic Professional Edition for Windows 5.0
- Microsoft Visual Basic Professional Edition for Windows 6.0
- Microsoft Visual Basic Enterprise Edition for Windows 5.0
- Microsoft Visual Basic Enterprise Edition for Windows 6.0
This article was previously published under Q216664 SUMMARY You can intercept keyboard input before it reaches a
control by creating a keyboard hook. The example below illustrates how to
intercept the ENTER key before it reaches a TreeView control.
WARNING: Failure to unhook the keyboard hook before exiting your
application will result in errors, Invalid Page Faults, and data loss. This is
caused by the system still pointing to your KeyboardProc() function, which no
longer exists because it has not been notified of the change.
Always unhook the keyboard upon exiting the application. This is
especially important while debugging a program that uses this technique within
the Microsoft Visual Basic Development Environment. Clicking the END button on the toolbar or selecting END from the Run menu without unhooking first will cause an Invalid Page Fault and
close Microsoft Visual Basic without giving you a chance to save your code. For
this reason it is best to test hooks in the EXE rather than from the IDE.
Modification Type: | Minor | Last Reviewed: | 8/11/2006 |
---|
Keywords: | kbAPI kbCtrl kbhowto kbTreeView KB216664 |
---|
|