Author Topic: How to get the mousewheel's case by Vlisp method ?  (Read 5131 times)

0 Members and 1 Guest are viewing this topic.

chlh_jd

  • Guest
How to get the mousewheel's case by Vlisp method ?
« on: April 25, 2011, 11:32:38 AM »
Hi you guys , How to get the mousewheel's case by Vlisp method .
I search by google , and found  mousewheel's case can be easy get by other Computer Language such as JavaScript , VC , VB etc. 
however, how to get it by Vlisp ; thoutgh "USER32.DLL" or other DYN method ?

Lee Mac

  • Seagull
  • Posts: 12926
  • London, England
Re: How to get the mousewheel's case by Vlisp method ?
« Reply #1 on: April 25, 2011, 11:53:18 AM »
Sorry, what do you mean by 'mousewheel's case'?

Crank

  • Water Moccasin
  • Posts: 1503
Re: How to get the mousewheel's case by Vlisp method ?
« Reply #2 on: April 25, 2011, 06:16:52 PM »
Hi you guys , How to get the mousewheel's case by Vlisp method .
I search by google , and found  mousewheel's case can be easy get by other Computer Language such as JavaScript , VC , VB etc. 
however, how to get it by Vlisp ; thoutgh "USER32.DLL" or other DYN method ?
I don't know a vlisp method, but I think, you can look for the value of:
Code: [Select]
(acet-sys-keystate 4); Middle mouse button (three-button mouse)

Quote
(acet-sys-keystate keycode);   Check state of virtual key.

Arguments
keycode The code for the virtual key to test.

Return Values
The status of the specified virtual key:

If the high-order bit is 1, the key is down; otherwise, it is up.
If the low-order bit is 1, the key is toggled. A key, such as the CAPS LOCK key, is toggled if it is turned on. The key is off and untoggled if the low-order bit is 0. A toggle key's indicator light (if any) on the keyboard will be on when the key is toggled, and off when the key is untoggled.

See the documentation for the GetKeyState() Win32 function for additional details.
Vault Professional 2023     +     AEC Collection

chlh_jd

  • Guest
Re: How to get the mousewheel's case by Vlisp method ?
« Reply #3 on: April 26, 2011, 08:10:30 AM »
Hi , Lee Mac .
I mean that how to catch and determine the case when the mousewheel is forward or backward Scrolled  or Pressed .

Thanks Crank a lot !
however when not has the ExpressTools in my ACAD, how to get that ?

 

chlh_jd

  • Guest
Re: How to get the mousewheel's case by Vlisp method ?
« Reply #4 on: April 28, 2011, 02:37:56 AM »
« Last Edit: April 28, 2011, 02:43:27 AM by chlh_jd »

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: How to get the mousewheel's case by Vlisp method ?
« Reply #5 on: May 05, 2011, 10:06:49 AM »
however when not has the ExpressTools in my ACAD, how to get that ?

Should be included on your ACAD disk, try to install/repair and add ExpressTools to the install.
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

xiaxiang

  • Guest
Re: How to get the mousewheel's case by Vlisp method ?
« Reply #6 on: May 05, 2011, 08:42:12 PM »
however when not has the ExpressTools in my ACAD, how to get that ?
Should be included on your ACAD disk, try to install/repair and add ExpressTools to the install.
Let's talk about doing that without ExpressTools.

alanjt

  • Needs a day job
  • Posts: 5352
  • Standby for witty remark...
Re: How to get the mousewheel's case by Vlisp method ?
« Reply #7 on: May 06, 2011, 12:33:07 AM »
Code: [Select]
(defun c:Test (/ lst)
  (setq lst (list (acet-sys-keystate 4)))
  (while (eq 5 (car (grread T 15 0)))
    (if (/= (car (setq lst (cons (acet-sys-keystate 4) lst))) (cadr lst))
      (alert "Middle button pressed!")
    )
  )
  (princ)
)

It's a little funky if you middle click and drag the mouse.
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

chlh_jd

  • Guest
Re: How to get the mousewheel's case by Vlisp method ?
« Reply #8 on: May 09, 2011, 07:57:23 AM »
Hi , Alan .
Even use "delay" method , it can't princ any result in my SP2 ACAD2004 version .
Code: [Select]
(defun c:Test (/ lst)
  (setq lst (list (acet-sys-keystate 4)))
  (command "delay" "1000")
  (while (eq 5 (car (grread T 15 0)))
    (if (/= (car (setq lst (cons (acet-sys-keystate 4) lst)))
    (cadr lst)
)
      (progn (princ lst)
     (princ "\nMiddle button pressed!")
      )
    )
  )
  (princ)
)

chlh_jd

  • Guest
Re: How to get the mousewheel's case by Vlisp method ?
« Reply #9 on: May 09, 2011, 08:14:34 AM »
here's a Example for MouseHook by VBA
http://www.vbaexpress.com/kb/getarticle.php?kb_id=890
Code: [Select]
' Class module for ActiveX dll
 
Option Compare Text
Option Explicit
 
Private frm As Object
Private intCancel As Integer
Public Event MouseWheel(Cancel As Integer)
 
Public Property Set Form(frmIn As Object)
Set frm = frmIn
End Property
 
Public Property Get MouseWheelCancel() As Integer
MouseWheelCancel = intCancel
End Property
 
Public Sub SubClassHookForm()
    lpPrevWndProc = SetWindowLong(frm.hwnd, GWL_WNDPROC, _
    AddressOf WindowProc)
    Set CMouse = Me
End Sub
 
Public Sub SubClassUnHookForm()
    Call SetWindowLong(frm.hwnd, GWL_WNDPROC, lpPrevWndProc)
End Sub
 
Public Sub FireMouseWheel()
    RaiseEvent MouseWheel(intCancel)
End Sub
 
 
 ' Standard Module Code
Option Compare Text
Option Explicit
 
Public CMouse As CMouseWheel
Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" _
(ByVal hwnd As Long, _
ByVal nIndex As Long, _
ByVal dwNewLong As Long) As Long
 
Public 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
 
Public Const GWL_WNDPROC = -4
Public Const WM_MouseWheel = &H20A
Public lpPrevWndProc As Long
Public Function WindowProc(ByVal hwnd As Long, _
    ByVal uMsg As Long, _
    ByVal wParam As Long, _
    ByVal lParam As Long) As Long
    Select Case uMsg
    Case WM_MouseWheel
        CMouse.FireMouseWheel
        If CMouse.MouseWheelCancel = False Then
            WindowProc = CallWindowProc(lpPrevWndProc, hwnd, uMsg, wParam, lParam)
        End If
        
    Case Else
        WindowProc = CallWindowProc(lpPrevWndProc, hwnd, uMsg, wParam, lParam)
    End Select
End Function
 
 
 
 ' Subs coded: Form LOAD Code/ Form CLOSE code/ clsMouseWheel_MouseWheel code
 ' Make sure you have referenced the MouseWheel.dll before you insert this code.  Also
 ' Ensure that you are not going to overwriite an existing code if you are cutting and
 ' pasting.  Either copy before or after you existing code.
 
Option Compare Database
Option Explicit
 
Private WithEvents clsMouseWheel As MouseWheel.CMouseWheel
 
Private Sub Form_Load()
    Set clsMouseWheel = New MouseWheel.CMouseWheel
    Set clsMouseWheel.Form = Me
    clsMouseWheel.SubClassHookForm
End Sub
 
Private Sub Form_Close()
    clsMouseWheel.SubClassUnHookForm
    Set clsMouseWheel.Form = Nothing
    Set clsMouseWheel = Nothing
End Sub
 
Private Sub clsMouseWheel_MouseWheel(Cancel As Integer)
    MsgBox "The Mouse Wheel has been disabled. Record shouldn't advance."
    Cancel = True
End Sub