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
Solved

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

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

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…
Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

856 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