Article ID: 224302 - Last Review: July 13, 2004 - Revision: 2.1 How To Suppress a TextBox Control's Popup MenuThis article was previously published under Q224302 On This PageSUMMARY
When a user right clicks a textbox, the standard textbox popup menu appears. This article demonstrates how to suppress the textbox popup menu.
MORE INFORMATION
When a user right clicks a textbox, the textbox window receives a WM_CONTEXTMENU message. When the WM_CONTEXTMENU message is received, the textbox window shows the popup menu. A window procedure can capture all WM_CONTEXTMENU messages sent to a textbox window, thus suppressing the default popup window.
WARNING: This sample replaces the WindowProc of the text box window using a technique called a hook. Failure to unhook a window before its imminent destruction results in application errors, invalid page faults, and data loss. This is due to the fact that the new WindowProc function being pointed to no longer exists, but the window has not been notified of the change. Always unhook the sub-classed window upon unloading the sub-classed form or exiting the application. This is especially important while debugging an application that uses this technique within the Microsoft Visual Basic Development Environment. Pressing the END button on the toolbar or selecting End from the Run menu without unhooking will cause an invalid page fault and close Microsoft Visual Basic. NOTE: This functionality is not available in any release of Microsoft Visual Basic for Applications (VBA) prior to Microsoft Office 2000. Step-by-Step Example
REFERENCES
For additional information, please see the following articles in the Microsoft Knowledge Base:
168795
(http://support.microsoft.com/kb/168795/EN-US/
)
How To Hook Into a Window's Messages Using AddressOf
"Dan Appleman's Visual Basic Programmer's Guide to the Win32 API" by Dan Appleman170570 (http://support.microsoft.com/kb/170570/EN-US/ ) How To Build a Windows Message Handler with AddressOf in VB Platform Software Development Kit (SDK) Online Help (http://msdn.microsoft.com/library/default.asp?URL=/library/psdk/portals/mainport.htm) APPLIES TO
| Article Translations
|
Back to the top
