| Author |
Message |
srinivasan
Guest
|
Posted:
Mon Mar 14, 2005 10:01 am Post subject:
Prevent Right Click |
|
|
Hello all,
How to prevent the right click in the drawing screen.
I tried with the right click settings but it gives me either
the popup menu or repeats last command.
I want the right click to produce no result in certain commands and to produce the same in some other commands.How to get this.
Thanks in advance.
Sri
|
|
| Back to top |
|
 |
Geometer Zopp (Kurt Pesen
Guest
|
Posted:
Mon Mar 14, 2005 7:44 pm Post subject:
Re: Prevent Right Click |
|
|
Just a guess, did not try that...
what about changing the Menu Part containing the context Menus (POP5xx)?
"srinivasan" <nospam@address.withheld> schrieb im Newsbeitrag
news:28142708.1110776957009.JavaMail.jive@jiveforum2.autodesk.com...
| Quote: | Hello all,
How to prevent the right click in the drawing screen.
I tried with the right click settings but it gives me either
the popup menu or repeats last command.
I want the right click to produce no result in certain commands and to
produce the same in some other commands.How to get this.
Thanks in advance.
Sri |
|
|
| Back to top |
|
 |
Nathan Taylor
Guest
|
Posted:
Tue Mar 15, 2005 2:49 am Post subject:
Re: Prevent Right Click |
|
|
The following code can be used to disable right clicks in any windows belonging to the current AutoCAD session.
| Code: |
Option Explicit
Private Const WH_MOUSE_LL As Long = 14
Private Const HC_ACTION As Long = 0&
Private Const WM_RBUTTONDOWN As Long = &H204
Private Const WM_RBUTTONUP As Long = &H205
Private Declare Function CallNextHookEx Lib "user32.dll" (ByVal hHook As Long, ByVal ncode As Long, ByVal wParam As Long, lParam As Any) As Long
Private Declare Function GetActiveWindow Lib "user32.dll" () As Long
Private Declare Function GetModuleHandle Lib "kernel32.dll" Alias "GetModuleHandleA" (ByVal lpModuleName As String) As Long
Private Declare Function GetWindowThreadProcessId Lib "user32.dll" (ByVal hwnd As Long, lpdwProcessId As Long) As Long
Private Declare Function SetWindowsHookEx Lib "user32.dll" Alias "SetWindowsHookExA" (ByVal idHook As Long, ByVal lpfn As Long, ByVal hmod As Long, ByVal dwThreadId As Long) As Long
Private Declare Function UnhookWindowsHookEx Lib "user32.dll" (ByVal hHook As Long) As Long
Private lngMouseHookHandle As Long
Public Sub DisableRightClick()
lngMouseHookHandle = SetWindowsHookEx(WH_MOUSE_LL, AddressOf LowLevelMouseProc, GetModuleHandle(vbNullString), 0&)
End Sub
Public Sub EnableRightClick()
Call UnhookWindowsHookEx(lngMouseHookHandle)
End Sub
Public Function LowLevelMouseProc(ByVal ncode As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Dim lpdwProcessId As Long
If GetWindowThreadProcessId(GetActiveWindow, lpdwProcessId) = GetWindowThreadProcessId(ThisDrawing.Application.hwnd, lpdwProcessId) Then
If ncode = HC_ACTION Then
Select Case wParam
Case WM_RBUTTONDOWN
LowLevelMouseProc = 1
Exit Function
Case WM_RBUTTONUP
LowLevelMouseProc = 1
Exit Function
End Select
End If
End If
LowLevelMouseProc = CallNextHookEx(lngMouseHookHandle, ncode, wParam, lParam)
End Function
|
|
|
| Back to top |
|
 |
srinivasan
Guest
|
Posted:
Tue Mar 15, 2005 9:41 am Post subject:
Re: Prevent Right Click |
|
|
Thanks zopp for your reply.
removing from the menu will remove the right
click completely.But what i need is to control the
right click i.e allowing right click when needed.
regards
Sri |
|
| Back to top |
|
 |
srinivasan
Guest
|
Posted:
Tue Mar 15, 2005 9:46 am Post subject:
Re: Prevent Right Click |
|
|
Thanks taylor
I am having a problem in executing the SetWindowsHookEx
function.It gives me an compile error in the 'AddressOf' statement.I am working in vba.How to solve this.
Regards
Sri |
|
| Back to top |
|
 |
srinivasan
Guest
|
Posted:
Wed Mar 16, 2005 4:27 pm Post subject:
Re: Prevent Right Click |
|
|
I am using VBA and SetWindowsHookEx
function gives me an compile error in the 'AddressOf' statement.
Regards
Sri |
|
| Back to top |
|
 |
Nathan Taylor
Guest
|
Posted:
Fri Mar 18, 2005 3:45 am Post subject:
Re: Prevent Right Click |
|
|
Sorry about the delay. Do you have the LowLevelMouseProc function in a forms code. I think the 'AddressOf' statement requires the function it is calling to be in a standard module.
Regards - Nathan |
|
| Back to top |
|
 |
bcoward
Guest
|
Posted:
Fri Mar 18, 2005 9:17 am Post subject:
Re: Prevent Right Click |
|
|
The AddressOf operator came about with VBA v6. I think that is 2002 and later. Without this VBA object model you can't subclass within the IDE IIRC.
Regards,
Bob Coward
CADS, Inc |
|
| Back to top |
|
 |
srinivasan
Guest
|
Posted:
Fri Mar 18, 2005 10:01 am Post subject:
Re: Prevent Right Click |
|
|
I couldnt find any such LowLevelMouseProc functions.
Regards
Sri |
|
| Back to top |
|
 |
|
|
|
|