Solved

VB6 - How to show a Popup Menu while rightclicking a text box?

Posted on 2008-10-30
4
314 Views
Last Modified: 2008-10-30
Hi Experts,

I have a text box that I want to show a popup menu when the user rights click on it. I have tried the code on Mouse_Down like I usually use for the form but it didn't work. It shows the normal popup menu of the text box; the one that has "copy, cut etc..."

Please check my code below. Is there anything missing that I have to set for the textbox?
Private Sub txt_body_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
 

        If Button = vbRightButton Then

           Me.PopupMenu Me.mnu_Main

        End If

        

End Sub

Open in new window

0
Comment
Question by:feesu
  • 2
  • 2
4 Comments
 
LVL 11

Accepted Solution

by:
Antagony1960 earned 250 total points
ID: 22839816
One way is to temporarily disable the textbox while displaying the popup.
0
 

Author Comment

by:feesu
ID: 22839833
Is this how all people do??
0
 
LVL 11

Expert Comment

by:Antagony1960
ID: 22839894
Not always, the problem is that you have to overcome the existing context menu. It doesn't display if the control is disabled, but a disabled textbox changes color and the focus jumps away so it's an ugly method. The only other way I know of way is to use the API to hide the default context menu. Check out this solution.
0
 

Author Comment

by:feesu
ID: 22839918
I prefer the simple solution. Thanks.
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now