How do disable mouse wheel on Drop List?

Thanks for the help. Need a little bit more on how to structure the code for 100s of windowprocs.

Can I put the windowproc in an object?

{
private LP originalWindowProc

WindowProc( hwnd, uMsg, wParam, lParam) {
if (wParam == WM_MOUSEWHEEL) {
return 0;
(originalWindowProc)(hwnd, uMsg, wParam, lParam)
how do I call a pointer in clarion?
}

Anyone have cw sample code using

HHOOK SetWindowsHookExA(
  int       idHook,
  HOOKPROC  lpfn,
  HINSTANCE hmod,
  DWORD     dwThreadId
);

No you cannot put a WindowProc directly in an object as the first parameter would change to the object instance (self)

That said, you can write a local procedure and use that from an object.

Note, your code looks like C, you’ll need to write it in CW (clarion for windows)

The somewhat un-obvious trick will be to be able to retrieve the origWndProc from within the WndProc itself. I used these a decade ago, I assume they’re still good :wink:

  SetProp   (LONG xHWND, _POINTER xlpString, HANDLE xhData),BOOL  ,PASCAL,RAW,NAME('SetPropA')             
  GetProp   (LONG xHWND, _POINTER xlpString               ),HANDLE,PASCAL,RAW,NAME('GetPropA')             
  RemoveProp(LONG xHWND, _POINTER xlpString               ),HANDLE,PASCAL,RAW,NAME('RemovePropA'),PROC

Before going too nuts with hooking and subclassing, maybe look at the help for PROP:WheelScroll.

Maybe you can find a value that satisfies your requirements. I’ve never used it.

Thanks.

That would have been great, had it worked.

equ{prop:wheelscroll} = 3000

had no impact. Tried 32767, 30000, 255 (even 0 to see if doc was wrong.)

equ contains the field number, or you forgot the ?

Just thought I’d ask

I wish. Thanks again.

CreateDropDownListString procedure(short equ, short parent, short theLine, short theColumn, string theStr, short dropAmount)
  code
    Create(equ, create:droplist, parent)
    compile('****',KCONTROLTEST=1)
       ControlAdd(equ, equ, 0{prop:handle}, 'CreateDropDownListString')
    ****

    equ{prop:drop} = dropAmount
    equ{prop:from} = theStr
    equ{prop:format} = KDropListFormatStringString
    equ{prop:font,1}= KDropListFont
    equ{prop:font,2}= KDropListFontSize
    equ{prop:font,4}= KDropListFontWeight
    SetControlPosition(equ, theLine, theColumn)
    equ{prop:vscroll} = 1
    equ{prop:wheelscroll} = 3000
  return

Mininmal changes in Smart Zoom template will do the trick.

Hi,

My app is all hand code, so I would be dissecting a sample app, correct?

Ive got a hook working(15 seconds of really good testing…) now that disables the wheel for the entire app.

Will the template show me something better?

myMouseHook procedure(long ncode, long wparam, long lparam),pascal, long
...
     api_CallNextHookEx(Long,Long,Long,Long),Long,Raw,Pascal,NAME('CallNextHookEx')
    api_SetWindowsHookEx(Long,Long,Long,Long),Long,Raw,Pascal,Name('SetWindowsHookExA')

...
  CODE
        open(AppFrame)
        ACCEPT
            if (firstrun)
                api_SetWindowsHookEx(14, address(myMouseHook), 0, 0)
 ! first parameter = WH_MOUSE_LL = 14 = Installs a hook procedure that monitors low-level mouse input events. For more information, see the LowLevelMouseProc hook procedure.
  ! 2nd parameter = address(myMouseHook)
  ! 3rd null HINSTANCE
  ! 4th 0 threadid

...

myMouseHook procedure(long ncode, long wparam, long lparam)
hMouse long (0)
code
  ! per https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-callnexthookex
  ! hMouse is ignored
  if (ncode >= 0) and (wparam = WM_MOUSEWHEEL)
    return 1
  else
    return api_CallNextHookEx(hMouse, ncode, wParam, lparam)
  end

The template just generates one call of a method for each list control in each window procedure in an app. In hand coded project one can do the same manually (hand code project is included in the package).

Hi Mike,

I see what you did there with storing the original call back address. Clever.

Jared

Returning 0 on WM_MOUSEWHEEL message will completely disable nouse wheel for a control:

  CASE wMsg 
  OF WM_MOUSEWHEEL
    RETURN 0

0 for WndProc and 1 for Hook. Correct?

https://msdn.microsoft.com/en-us/library/ms644986(v=VS.85).aspx

Return value

Type:

Type: LRESULT

If nCode is less than zero, the hook procedure must return the value returned by CallNextHookEx .

If nCode is greater than or equal to zero, and the hook procedure did not process the message, it is highly recommended that you call CallNextHookEx and return the value it returns; otherwise, other applications that have installed WH_MOUSE_LL hooks will not receive hook notifications and may behave incorrectly as a result. If the hook procedure processed the message, it may return a nonzero value to prevent the system from passing the message to the rest of the hook chain or the target window procedure.

myMouseHook procedure(long ncode, long wparam, long lparam)
hMouse long (0)
code
  ! per https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-callnexthookex
  ! hMouse is ignored
  if (ncode >= 0) and (wparam = WM_MOUSEWHEEL)
    return 1
  else
    return api_CallNextHookEx(hMouse, ncode, wParam, lparam)
  end

Here I’m talking about WndProc only. Regarding mouse hooks, I used them in my Script Player product, below is mouse hook code, but there I don’t process wheel messages:

wh::MouseProc                 PROCEDURE(LONG pCode, UNSIGNED wParam, LONG lParam)
mouseInfo                       &MOUSEHOOKSTRUCT, AUTO        !-- in lParam 
mouseData                       LIKE(TMouseHookData), AUTO
pt                              LIKE(POINT), AUTO
vLPressed                       BOOL, AUTO    !-- left mouse button pressed
vRPressed                       BOOL, AUTO    !-- right mouse button pressed
ctrl                            &TMouseHooker
  CODE
  IF pCode < 0
    RETURN wh::CallNextHookEx(ctrlMgr.hHook, pCode, wParam, lParam)
  END
  
  mouseInfo &= (lParam)
  
  !-- find an instance
  ctrl &= ctrlMgr.GetControl(mouseInfo.hwnd)
  IF ctrl &= NULL
    !-- this control is not in the list
    RETURN wh::CallNextHookEx(ctrlMgr.hHook, pCode, wParam, lParam)
  END
  
  !-- action
  mouseData.Action = wParam
  
  !-- screen pos
  pt = mouseInfo.pt
  mouseData.ScreenPt = pt
  
  !-- client pos
  wh::ScreenToClient(mouseInfo.hwnd, pt)
  mouseData.ClientPt = pt
  
  mouseData.LPressed = CHOOSE(BAND(wh::GetAsyncKeyState(VK_LBUTTON), 08000h) > 0)
  mouseData.RPressed = CHOOSE(BAND(wh::GetAsyncKeyState(VK_RBUTTON), 08000h) > 0)
  
  IF ctrl.MouseProc(mouseData)
    RETURN wh::CallNextHookEx(ctrlMgr.hHook, pCode, wParam, lParam)
  END
  
  RETURN 0

Update:

I add the wndproc to filter all mouse wheel messages for each drop down list as they are created. The mouse scroll wheel has no effect when the mouse is over the drop down list. This is the desired behavior.

But, when the drop down list is selected, moving the mouse scroll wheel almost anywhere other than the over the drop down list caused the option to change w/o dropping down the list.

I’m starting to sprinkle the wndproc to sheet and tab controls and the window.

Any suggestions?

Yup, when mouse corsor is not over a dropdown box, WM_MOUSEWHEEL message never fires, but the value is changing. Maybe Spy++ will help to find a solution.

Thanks. Already been there.

It appears to be a user defined message.

Possibly try a call to Debuger.GetEventDescr_WM inside of your WndProc, that’s sorta like Spy++ but uses SV’s namings for events, which includes some of the user defined ones.

see https://github.com/MarkGoldberg/ClarionCommunity/blob/master/CW/Shared/Src/debuger.clw for the class and method.

1 Like

Thanks. I see some TMM_ names come back on wm_user + low numbers.

No matches to the ones I see in spy++.

Hello,

Sorry to raise this thread, but if someone in the future needs info on how to get other events.

It is possible using PROP:WndProc and PROP:ClientWndProc. To find more about it you need to search as WndProc or ClientWndProc in help index.

For window events you can use both, depends on where you need it. For lists, on the other hand, it is necessary to use only WndProc. Since list behaves as “attached window” to window.

In the end I have found example for list from Brahn: https://github.com/fushnisoft/ClarionClasses/blob/master/ListHScroll/ListHScroll.clw