|
|
Title | Make a TextBox control that does not display a context menu in VB .NET |
Description | Make a TextBox control that does not display a context menu in VB .NET. It overrides the control's WndProc subroutine and ignores WM_CONTEXTMENU messages. |
Keywords | TextBox, context menu, popup menu |
Categories | VB.NET, Controls |
|
|
The NoCtxMnuTextBox class inherits from TextBox. It overrides the TextBox's WndProc and ignores any WM_CONTEXTMENU messages that it sees. It passes all other messages on to the parent's version of WndProc for processing.
|
|
Public Class NoCtxMnuTextBox
Inherits System.Windows.Forms.TextBox
...
Protected Overrides Sub WndProc(ByRef m As _
System.Windows.Forms.Message)
Const WM_CONTEXTMENU As Integer = &H7B
If m.Msg <> WM_CONTEXTMENU Then
MyBase.WndProc(m)
End If
End Sub
End Class
|
|
To get this program to work, you need to load and compile it. Then right-click on the Toolbox and select Add/Remove Items. Click Browse, browse to the program's bin directory, and select the executable that you just built. This adds the control to the Toolbox.
Now use the Toolbox to add the control to the form.
|
|
|
|
|
|