3个回答
2013-08-17
展开全部
你可以用JS屏蔽 CTRL 和鼠标右键但是真要复制你也是不能左右的 <script language="javascript">function click(e) {
if (document.all) {
if (event.button==1||event.button==2||event.button==3) {
oncontextmenu='return false';
}
}
if (document.layers) {
if (e.which == 3) {
oncontextmenu='return false';
}
}
}
if (document.layers) {
document.captureEvents(Event.MOUSEDOWN);
}
document.onmousedown=click;
document.oncontextmenu = new Function("return false;") var travel=true
var hotkey=17 /* hotkey即为热键的键值,是ASII码,这里99代表c键 */
if (document.layers)
document.captureEvents(Event.KEYDOWN)
function gogo(e)
{ if (document.layers) {
if (e.which==hotkey&&travel){
alert("操作错误.或许是您按错了按键!"); } }
else if (document.all){
if (event.keyCode==hotkey&&travel){ alert("操作错误.或许是您按错了按键!"); }}
} document.onkeydown=gogo </script>
if (document.all) {
if (event.button==1||event.button==2||event.button==3) {
oncontextmenu='return false';
}
}
if (document.layers) {
if (e.which == 3) {
oncontextmenu='return false';
}
}
}
if (document.layers) {
document.captureEvents(Event.MOUSEDOWN);
}
document.onmousedown=click;
document.oncontextmenu = new Function("return false;") var travel=true
var hotkey=17 /* hotkey即为热键的键值,是ASII码,这里99代表c键 */
if (document.layers)
document.captureEvents(Event.KEYDOWN)
function gogo(e)
{ if (document.layers) {
if (e.which==hotkey&&travel){
alert("操作错误.或许是您按错了按键!"); } }
else if (document.all){
if (event.keyCode==hotkey&&travel){ alert("操作错误.或许是您按错了按键!"); }}
} document.onkeydown=gogo </script>
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2013-08-17
展开全部
以下是代码
--------
新建一个模块,添加以下代码,注意一定要放在模块中
Option Explicit
Private Const GWL_WNDPROC = (-4)
Private Const WM_RBUTTONDOWN = &H204
Public Const WM_COPY = &H301
Private 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
Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long) As Long
Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private prevWndProc As Long
Private Function WndProc(ByVal hWnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
If Msg = WM_COPY Then
Else
WndProc = CallWindowProc(prevWndProc, hWnd, Msg, wParam, lParam)
End If
End Function
Sub DisableCopy(TargetTextBox As TextBox)
prevWndProc = GetWindowLong(TargetTextBox.hWnd, GWL_WNDPROC)
SetWindowLong TargetTextBox.hWnd, GWL_WNDPROC, AddressOf WndProc
End Sub
--------------
然后再窗体代码中添加
Private Sub Form_Load()
DisableCopy Text1
End Sub
即可,text1是想要禁止复制的textbox
--------
新建一个模块,添加以下代码,注意一定要放在模块中
Option Explicit
Private Const GWL_WNDPROC = (-4)
Private Const WM_RBUTTONDOWN = &H204
Public Const WM_COPY = &H301
Private 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
Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long) As Long
Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private prevWndProc As Long
Private Function WndProc(ByVal hWnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
If Msg = WM_COPY Then
Else
WndProc = CallWindowProc(prevWndProc, hWnd, Msg, wParam, lParam)
End If
End Function
Sub DisableCopy(TargetTextBox As TextBox)
prevWndProc = GetWindowLong(TargetTextBox.hWnd, GWL_WNDPROC)
SetWindowLong TargetTextBox.hWnd, GWL_WNDPROC, AddressOf WndProc
End Sub
--------------
然后再窗体代码中添加
Private Sub Form_Load()
DisableCopy Text1
End Sub
即可,text1是想要禁止复制的textbox
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2013-08-17
展开全部
请说的明确一点
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询