how to get CRTL + WHEEL

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

Post Reply
User avatar
AUGE_OHR
Posts: 2117
Joined: Sun Aug 25, 2019 3:12 pm
DBs Used: DBF, PostgreSQL, MySQL, SQLite
Location: Hamburg, Germany

how to get CRTL + WHEEL

Post by AUGE_OHR »

hi

i can get Wheel this Way

Code: Select all

   CREATE EVENT PROCNAME ImageWheelEvent() HWND ImageEdit.HANDLE STOREINDEX nIndex
   EventProcessAllHookMessage( nIndex, .T. )

Code: Select all

FUNCTION ImageWheelEvent()
LOCAL nHWnd   := EventHWND()
LOCAL nWParam := EventWPARAM()
LOCAL lCtrl   := HMG_VirtualKeyIsPressed( VK_CONTROL )

   IF HMG_GetLastMouseMessage (@nhWnd) == WM_MOUSEWHEEL .AND.  nhWnd == ImageEdit.HANDLE // .AND. lCtrl = .T.
      HMG_CleanLastMouseMessage()

      IF HIWORD( nWParam ) == 120
         keybd_event(VK_SUBTRACT,0,0,0)
      ELSE
         keybd_event(VK_ADD,0,0,0)
      ENDIF
   ENDIF
   HMG_CleanLastVirtualKeyDown()
RETURN Nil
but i can´t get CTRL and Wheel, WHY :?:
it work without CTRL using Wheel so what do i have to change :idea:
have fun
Jimmy
User avatar
Rathinagiri
Posts: 5482
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Contact:

Re: how to get CRTL + WHEEL

Post by Rathinagiri »

Have you tried to use the following function? It returns the current keystate.

GetKeyState ( VK_Code ) --> return nKeyState
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
User avatar
AUGE_OHR
Posts: 2117
Joined: Sun Aug 25, 2019 3:12 pm
DBs Used: DBF, PostgreSQL, MySQL, SQLite
Location: Hamburg, Germany

Re: how to get CRTL + WHEEL

Post by AUGE_OHR »

hi,

have made a Sample to demonstrate my Problem.
Zoom.zip
(21.08 KiB) Downloaded 88 times
load a Image and use Wheel to "zoom" in Image
but i want to use "CTRL + Wheel"

FUNCTION ImageWheelEvent() is on Bottom of Demo Source.
how to modify to use "CTRL + Wheel" :idea:
have fun
Jimmy
User avatar
andyglezl
Posts: 1461
Joined: Fri Oct 26, 2012 7:58 pm
Location: Guadalajara Jalisco, MX
Contact:

Re: how to get CRTL + WHEEL

Post by andyglezl »

En mi programa quise utilizar esto, pero no se como detectar si la rueda va hacia
adelante o hacia atrás...
*------------------------------------------------------------------------------
In my program I wanted to use this, but I don't know how to detect if the wheel goes towards
forward or backward ...



#define WM_VSCROLL 277

***IF nLastMM == WM_MOUSEWHEEL .AND. nhWnd == ImageEdit.HANDLE
IF nMsg == WM_VSCROLL .AND. GET_STATE_VK_CONTROL()=.T. <====================
Andrés González López
Desde Guadalajara, Jalisco. México.
User avatar
AUGE_OHR
Posts: 2117
Joined: Sun Aug 25, 2019 3:12 pm
DBs Used: DBF, PostgreSQL, MySQL, SQLite
Location: Hamburg, Germany

Re: how to get CRTL + WHEEL

Post by AUGE_OHR »

hi,
andyglezl wrote: Sat Jun 05, 2021 11:07 pm #define WM_VSCROLL 277
***IF nLastMM == WM_MOUSEWHEEL .AND. nhWnd == ImageEdit.HANDLE
IF nMsg == WM_VSCROLL .AND. GET_STATE_VK_CONTROL()=.T. <====================
have try it in my Sample ... but it seems not to react ... have no Scrollbar to scroll for "zoom"

IHMO it must be WM_MOUSEWHEEL which work in my Sample
i also can detect

Code: Select all

   nHIWORD := HIWORD( nWParam )
   nLOWORD := LOWORD( nWParam )

   IF nHIWORD = 120 .AND. nLOWORD = MK_CONTROL
         IF nHIWORD = 120        // .AND. ( nLOWORD = 8 .or. nLOWORD = 4  )
*            keybd_event(VK_SUBTRACT,0,0,0)
*            keybd_event(VK_SUBTRACT, 0, KEYEVENTF_KEYUP, 0 )
            SENDKEY( VK_SUBTRACT )
            // NEED after SENDKEY
            DO EVENTS
            onDummy( TIME(), "OK 120" )
Code is working step by step ( F8 )
but keybd_event() / SENDKEY() is NOT going to Target when press CTRL or SHIFT and scroll Wheel ...
have fun
Jimmy
User avatar
andyglezl
Posts: 1461
Joined: Fri Oct 26, 2012 7:58 pm
Location: Guadalajara Jalisco, MX
Contact:

Re: how to get CRTL + WHEEL

Post by andyglezl »

Code: Select all

FUNCTION ImageWheelEvent()
LOCAL nHWnd   := EventHWND()
LOCAL nMsg    := EventMSG()
LOCAL nWParam := EventWPARAM()
LOCAL nLParam := EventLPARAM()

LOCAL nLastMM := HMG_GetLastMouseMessage (@nhWnd,@nMsg,@nWParam,@nLParam)
LOCAL nLOWORD := LOWORD( nWParam )
LOCAL nHIWORD := HIWORD( nWParam )
LOCAL xKey    := HMG_GetLastVirtualKeyDown()
LOCAL lCtrl   := GetKeyState( VK_CONTROL )

    IF nLastMM == WM_MOUSEWHEEL .AND.  nhWnd == ImageEdit.HANDLE .AND. xKey = VK_CONTROL
*         HMG_CleanLastMouseMessage()
*         msgbox( "entre..." )
         IF HIWORD( nWParam ) == 120	// ???
            keybd_event(VK_SUBTRACT,0,0,0)
         ELSE
            keybd_event(VK_ADD,0,0,0)
         ENDIF
   ENDIF
   HMG_CleanLastVirtualKeyDown()
RETURN Nil

De esta forma funciona, pero de forma extraña...
tienes que mover el ratón al final, para que ejecute la acción...
*-------------------------------------------------------------------------------
This way it works, but in a strange way ...
you have to move the mouse at the end, so that it executes the action ...
Andrés González López
Desde Guadalajara, Jalisco. México.
User avatar
AUGE_OHR
Posts: 2117
Joined: Sun Aug 25, 2019 3:12 pm
DBs Used: DBF, PostgreSQL, MySQL, SQLite
Location: Hamburg, Germany

Re: how to get CRTL + WHEEL

Post by AUGE_OHR »

hi,
andyglezl wrote: Sun Jun 06, 2021 4:17 am This way it works, but in a strange way ...
i have change Code as i can not use Parameter at CREATE EVENT to call Function direct.

Code: Select all

FUNCTION ImageWheelEvent()
LOCAL nHWnd   := EventHWND()
LOCAL nMsg    := EventMSG()
LOCAL nWParam := EventWPARAM()
LOCAL nLParam := EventLPARAM()
// this are need fo WM_MOUSEWHEEL
LOCAL nHIWORD := HIWORD( nWParam )
LOCAL nLOWORD := LOWORD( nWParam )

   IF (nMsg == WM_MOUSEWHEEL ) .AND. nhWnd == ImageEdit.HANDLE
      IF nLOWORD = 8 // MK_CONTROL
         HMG_CleanLastMouseMessage()
         HMG_CleanLastVirtualKeyDown()

         DO CASE
            CASE nHIWORD = WHEEL_DELTA .or. nHIWORD = WHEEL_DELTA * 2 .or. nHIWORD = WHEEL_DELTA * 3
               Zoom(+1)
            CASE nHIWORD = 65416
               Zoom(-1)
         ENDCASE

      ENDIF
   ENDIF

RETURN Nil
ZOOMVIEW.ZIP
(4.03 KiB) Downloaded 89 times
have fun
Jimmy
Post Reply