Reprint-VB Disable the text box right-click menu and other functions

Source: Internet
Author: User

' ========================================================== ' | Module Name | Textboxdisableability ' | Description | Disable the function of the text box ' ==========================================================option explicitprivate Declare function SetWindowText Lib "user32" Alias "Setwindowtexta" (ByVal hwnd as Long, ByVal lpstring as String) as Longprivate Declare Fu Nction 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 Longprivate Declare Function getwindowlong Lib "user32" Alias "Getwin Dowlonga "(ByVal hwnd as Long, ByVal NIndex as Long) as Longprivate Declare Function setwindowlong Lib" user32 "Alias" Set Windowlonga "(ByVal hwnd as Long, ByVal NIndex as Long, ByVal Dwnewlong as Long) as longprivate Const Gwl_wndproc = ( -4) Pr  ivate Const Wm_cut = &h300 '-------------cut message Private Const wm_copy as Long = &h301 '-------------copy message Private Const Wm_paste as Long = &h302 '-------------paste message private ConsT wm_clear = &h303 '-------------Delete message [the deletion of the right-click menu]private Const Em_undo = &hc7 '-------------revoke the message Private Const Wm_con Textmenu = &h7b '-------------Right-click menu Private prevwndproc as Longprivate Function WndProc (ByVal hwnd as Long, ByVal MSG As long, ByVal WParam as Long, ByVal LParam as Long) as long Select case MSG case Wm_cut, Wm_copy, Wm_paste, Wm_clear, E M_undo, Wm_contextmenu ' handles custom events here, preferably empty case Else ' callback system function Handling WndProc = CallWindowProc (Prevwndproc, hwnd, MSG, WPa RAM, LParam) End selectend functionpublic Sub disableability (targettextbox as TextBox) ' Call this prevwndproc when the program starts = Getwind Owlong (Targettextbox.hwnd, Gwl_wndproc) SetWindowLong Targettextbox.hwnd, GWL_WNDPROC, AddressOf WndProcEnd Sub

  

Reprint-VB Disable the text box right-click menu and other functions

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.