How to prevent menu with right mouse click on textbox 
Author Message
 How to prevent menu with right mouse click on textbox

This must be easy, but I cannot find any documentation on this one:

How do I prevent that little popup menu from appearing when a user right
clicks on a textbox so I can create and display my own custom popup?

e-mail would be greatly appreciated as well as a response for everyone to
read.

thank you.

(VB-5, and 4{i think?})

-john

--
John Shelley
Soft-Sense
Software that makes Sense!




Sun, 02 Jan 2000 03:00:00 GMT  
 How to prevent menu with right mouse click on textbox

John,

For VB 5
Put in standard module:

Option Explicit
Public Const GWL_WNDPROC = (-4)
Public Const WM_RBUTTONDOWN = &H204
Declare Function CallWindowProc Lib "user32" Alias "CallWindowProcA" ( _
    ByVal lpPrevWndFunc As Long, _
    ByVal hwnd As Long, _
    ByVal MSG As Long, _
    ByVal wParam As Long, _
    ByVal lParam As Long _
) As Long
Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" ( _
    ByVal hwnd As Long, _
    ByVal nIndex As Long, _
    ByVal dwNewLong As Long _
) As Long
Declare Function Beep Lib "kernel32" ( _
ByVal dwFreq As Long, _
ByVal dwDuration As Long _
) As Long

Public PrevWindowProc As Long
Public NewWindowProc As Long

Public Function WindowProc(ByVal hwnd As Long, ByVal MSG As Long, ByVal
wParam As Long, ByVal lParam As Long) As Long
'*****new windows procedure**********
'have message eaten
Select Case MSG
    Case WM_RBUTTONDOWN                 'If an application processes this
message,
        Form1.PopupMenu Form1.mnuMenu   '
        WindowProc = 0                  'it should return zero.
        Exit Function
End Select
'continue
WindowProc = CallWindowProc(PrevWindowProc, hwnd, MSG, wParam, lParam)

End Function

Call it from form module
to kill default pop up menu:
Private Sub Text1_GotFocus() 'or another event
'provide address of new windows procedure
'and save address of current windows procedur
PrevWindowProc = SetWindowLong(Text1.hwnd, GWL_WNDPROC, AddressOf
WindowProc)
End Sub

to return back to default:
Private Sub Text1_LostFocus()
'to stop hook return to previous procedure
NewWindowProc = SetWindowLong(Text1.hwnd, GWL_WNDPROC, PrevWindowProc)
End Sub

For VB4 you have to use some kind of msghook, but idea is the same

Somebody in this groop suggested more simple solution for both VB5, VB4.
You can just disable textbox inside mouse_down event and enable it latter
after execution of your code.
It will make text box flash from black to gray, but I like it.

Let me know if you need more code.

Regards,
Vladimir



Quote:
> This must be easy, but I cannot find any documentation on this one:

> How do I prevent that little popup menu from appearing when a user right
> clicks on a textbox so I can create and display my own custom popup?

> e-mail would be greatly appreciated as well as a response for everyone to
> read.

> thank you.

> (VB-5, and 4{i think?})

> -john

> --
> John Shelley
> Soft-Sense
> Software that makes Sense!




Sun, 02 Jan 2000 03:00:00 GMT  
 How to prevent menu with right mouse click on textbox

--
Luca Faiazza



Quote:
> The kludge you mention must be the enabled property.  I've found that
this
> works, and with absolutely no flashing ..

> Sub Text1_MouseUp (...)

>    Text1.Enabled=false
>             text1.enabled=true
>             PopupMenu <whatever>

> Not that I truly endorse this hack, but I was experimenting when I
> accidentally placed the enabled properties adjacent to each other, and
the
> darn thing worked! I expected the either the textbox to flicker, or the
> default menu to show.  Neither happened.

Randy, that sounds great. In fact I have a solution that is same kind of
type than yours:

Put in any mouse down event that pops up a standard menu the following
lines:

If button = 2 Then SendKeys "{ESC}", False

The esc-pressing emulation sends the standard menu to the moon with
absolutely no flashing...

Luca



Sun, 02 Jan 2000 03:00:00 GMT  
 How to prevent menu with right mouse click on textbox

The kludge you mention must be the enabled property.  I've found that this
works, and with absolutely no flashing ..

Sub Text1_MouseUp (...)

        Text1.Enabled=false
            text1.enabled=true
            PopupMenu <whatever>

Not that I truly endorse this hack, but I was experimenting when I
accidentally placed the enabled properties adjacent to each other, and the
darn thing worked! I expected the either the textbox to flicker, or the
default menu to show.  Neither happened.

--
Randy Birch, MVP Visual Basic

Moderator, Fidonet Visual Basic Programmer's Conference
VBnet, The Visual Basic Developers Resource Centre
http://home.sprynet.com/sprynet/rasanen/



: [This followup was posted to microsoft.public.vb.syntax and a copy was
: sent to the cited author.]
:

: > This must be easy, but I cannot find any documentation on this one:
: >
: > How do I prevent that little popup menu from appearing when a user
right
: > clicks on a textbox so I can create and display my own custom popup?
: >
: > e-mail would be greatly appreciated as well as a response for everyone
to
: > read.
: >
: > thank you.
: >
: > (VB-5, and 4{i think?})
: >
: > -john
: >
: >
: > --
: > John Shelley
: > Soft-Sense
: > Software that makes Sense!

: >
: Sorry to be the bearer of bad news...
:
: You can't disable the menu. Someone passed me a kluge which causes it to
: be dismissed automatically but it still leaves an annoying flash. Best to

: work with another mouse click. Perhaps a ctrl+left mouse button.
:
: If you really want the kluge to try out, email me and I'll send it.
:
: -Stu
: --
: Nearly ready for take-off...
: GUI Gumdrops - Tasty Morsels for Windows Developers
: http://www.guigumdrops.com
:



Sun, 02 Jan 2000 03:00:00 GMT  
 How to prevent menu with right mouse click on textbox

[This followup was posted to microsoft.public.vb.syntax and a copy was
sent to the cited author.]


Quote:
> This must be easy, but I cannot find any documentation on this one:

> How do I prevent that little popup menu from appearing when a user right
> clicks on a textbox so I can create and display my own custom popup?

> e-mail would be greatly appreciated as well as a response for everyone to
> read.

> thank you.

> (VB-5, and 4{i think?})

> -john

> --
> John Shelley
> Soft-Sense
> Software that makes Sense!


Sorry to be the bearer of bad news...

You can't disable the menu. Someone passed me a kluge which causes it to
be dismissed automatically but it still leaves an annoying flash. Best to
work with another mouse click. Perhaps a ctrl+left mouse button.

If you really want the kluge to try out, email me and I'll send it.

-Stu
--
Nearly ready for take-off...
GUI Gumdrops - Tasty Morsels for Windows Developers
http://www.guigumdrops.com



Sun, 02 Jan 2000 03:00:00 GMT  
 How to prevent menu with right mouse click on textbox


Fri, 19 Jun 1992 00:00:00 GMT  
 How to prevent menu with right mouse click on textbox

IT IS possible!

behold... put this in the mouse down event:

If Button = vbRightButton Then
    Text1.Enabled = False
    Form2.Show vbModal
    Text1.Enabled = True
End If

Presto:  no more popup!



Fri, 07 Jan 2000 03:00:00 GMT  
 
 [ 7 post ] 

 Relevant Pages 

1. How to remove textbox right mouse click menu?

2. How to remove textbox right mouse click menu?

3. How to remove textbox right mouse click menu?

4. MENU: Prevent exit due to mouse click

5. Disabling right mouse click in standard textbox

6. Textbox - disable right mouse click

7. override right mouse click on textbox

8. Looking for lightweight Textbox control that does not hog up right mouse click

9. Disable mouse right click of TextBox

10. Context Menu's and right mouse click event

11. Right mouse button click popup menu

12. Display menu on right mouse click

 

 
Powered by phpBB® Forum Software