How do disable mouse wheel on ddl?


#1

C11 allows a mouse wheel to change a ddl value w/o the ddl being dropped nor selected by a click.

hover a mouse over a ddl then scroll the wheel and the selection changes.

I would like to disable the mouse wheel on non dropped lists.

All hand coded program.

Controls are created on the fly.

Any thoughts?


#2

ok, I’ll bite, what’s a DDL ?


#3

Perhaps it’s drop-down list.


#4

Hi,

sorry. It is a drop down list.


#5

I’m not sure why you’d care about how the user goes about changing a value. But to stop it, you’ll likely need a WndProc for each control where you want to suppress that behavior. I forget it’s likely something like WM_Wheel

see https://docs.microsoft.com/en-us/windows/desktop/inputdev/wm-mousewheel

Do you know how to write a WndProc for a control ?


#6

Users are changing values w/o knowing they are changing values.

Compare to a drop down list in excel. A mousewheel movement scrolls the page, not the selected entry of a dropped down list the cursor happens to be near.

That is what my users are expecting.

not sure about wndproc details. I can handle(pun…) it given a starting point.

create control…
(equ){prop:wndproc} = …

I’m ok with disabling mousewheel on all ddl, even when dropped.

LRESULT CALLBACK WindowProc(
  _In_ HWND   hwnd,
  _In_ UINT   uMsg,
  _In_ WPARAM wParam,
  _In_ LPARAM lParam
) {
   if (wParam == WM_MOUSEWHEEL) {
      return 0;
   }
}

something like that?


#7

Well, CW doesn’t have CALLBACK.
LRESULT can be equated,
but that’s not CW syntax.

Note: a WndProc will still need to make a CallWindowProc of the origWndProc at the end
otherwise, bad things happen.


#8

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?
}

#9

Anyone have cw sample code using

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

#10

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

#11

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.


#12

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.)


#13

equ contains the field number, or you forgot the ?

Just thought I’d ask


#14

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

#15

Mininmal changes in Smart Zoom template will do the trick.


#16

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

#17

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).


#18

Hi Mike,

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

Jared


#19

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

  CASE wMsg 
  OF WM_MOUSEWHEEL
    RETURN 0

#20

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