News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

ScrollBar handle of ListView control

Started by georgek01, January 15, 2007, 11:31:40 AM

Previous topic - Next topic

georgek01

Hello!

I need to get the handle of the scrollbars (vertical and horizontal) of a ListView control. I've been through the API documentation (Platform SDK: ms-help://MS.PSDKSVR2003R2.1033/shellcc/platform/commctls/scrollbars/scrollbars.htm) and cannot find a means to do this.

Any suggestions will be greatly appreciated!
What we have to learn to do, we learn by doing.

- ARISTOTLE (384-322 BC)

TNick

Hello, georgek01!
I don't know how scroll bars are implemented in ListView, but, if I would write (and I will :) such a control, I would implement scroll bars at creation time as standard scroll bars and not as stand alone controls. Anyway, this is what win32.hlp tells us about WM_HSCROLL's  lParam:
Quote from: win32.hlp
hwndScrollBar

Value of lParam. Identifies the control if WM_HSCROLL is sent by a scroll bar control. If WM_HSCROLL is sent by a window's standard scroll bar, hwndScrollBar is not used.
Same thing with vertical scroll bars.

If you tell us why you need it, maybe will find another way than using the handle...

Regards,
Nick

georgek01

Hello Nick,

Thanks for the response.

I've sub-classed the ListView control and use the WM_MOUSELEAVE message to check when the mouse has left the control. If the mouse moves over the header and scrollbars, this message is also sent - therefore, the user is unable to scroll because my code hides the ListView once the mouse is not over it any more.

I'd like to separately subclass the scrollbars so I can check their message que for mouse events, thus providing a means to determine if the mouse is still "inside" the ListView.

Regards, George


What we have to learn to do, we learn by doing.

- ARISTOTLE (384-322 BC)

TNick

Here is a quick solution, but it has to be tested, 'cause I don't know if WM_NCHITTEST will work. So, in your WM_MOUSELEAVE you can do this


INVOKE GetCursorPos, ADDR APointStruct
mov      eax,APointStruct.x
mov      ecx, APointStruct.y
shl        ecx, 16
mov      cx, ax
INVOKE  SendMessage, hWnd, WM_NCHITTEST,0,ecx


if eax=HTVSCROLL or whatever you are interested in, then don't hide the window (see the WM_NCHITTEST documentation)

I am really curious if this works...  :dazzled:

Nick


[later]
If it doesn't work like this (and even if it does) you may try to replace the SendMessage function with DefWindowProc
INVOKE DefWindowProc, hWnd, WM_NCHITTEST,0,ecx