Search Amazon:

Subclass Text & Combo Boxes
to Display PopUp Menus

Right clicking a textbox pops up the standard context menu with the Cut, Copy and Paste options. Often you need to display your own menu. You can by calling the PopupMenu command in the textbox's MouseUp event. However, the standard context menu still appears. You can remove it with subclassing.

Subclassing lets you process the messages Window's sends to your control allowing you to customize their behavior by reacting to or ignoring events that Visual Basic does not normally give you control over. Be forewarned, however, that subclassing removes much of the stability and robustness built into Visual Basic.

Subclass Text & Combo Boxes to Display PopUp Menus
Download Source Code

Discussion

For a thorough discussion of subclassing, visit my Sub-Class Forms to Intercept Windows Messages page. The code in this sample is just a variation of the concepts used there.

Instructions

Download the source code and run it. Right click the top textbox and comboboxes to verify they function as normal.

Right click the bottom textbox and comboboxes to see that they popup my own menu without displaying the normal context menu.

Sign In
  User Id 
  Password 


Submit Your Own Code and Articles




About TheScarms
About TheScarms

Ask me your programming questions

I read every email and answer all I can.

User Feedback: Be the first to add a comment! Items to Show:     

     
You must log in to post feedback.
Comment:    
 

If you use this code, please mention "www.TheScarms.com"

Email this page


TheScarms AppSentinel lets you securely copy protect and create evaluation versions of your software

TheScarms(tm) AppSentinel lets you quickly and easily create evaluation versions of your software and stop unauthorized copying and unregistered use of your programs!

Get your free
trial copy today!


      The World's Number 1 Web Host

© Copyright 2008 TheScarms