Solved

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

Posted on 2008-10-30
4
330 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

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

822 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