?
Solved

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

Posted on 2008-10-30
4
Medium Priority
?
352 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 11

Accepted Solution

by:
Antagony1960 earned 750 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
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…
Suggested Courses

752 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