Hi all,
I have recently attempted to use the DetectScroll method developed by CPearson: http://www.cpearson.com/excel/DetectScroll.htm
It no longer works because it is based on the "WM_VSCROLL" messages, which I cannot find in any window's message stream using Spy++.
From this observation, I tried scrolling with Window's Messages and Window's API functions only
Let's assume we have these handles:
The following does not work:
The following messages have not effect either:
the "Workbook" window appears to no longer be responding to WM_VSCROLL messages. Spy++ also shows a child window of EXCEL7 of class "NUIScrollbar", which makes me think that the EXCEL7 window no longer uses a standard vertical scroll bar, but a custom control.
Now if I use the following, I get to successfully scroll the scrollbox of the scrollbar, but I fail to update the window's scroll based on the new position of the scrollbar:
I also noticed this message successfully moves the scrollbox AND the window:
But I do not really like this last method since I cannot see this message in Spy++, so it is not how the system works natively...
I have also tried using the ScrollWindow and ScrollWindowEx functions to scroll the contents of the "Workbook" window, but I fail to see the cells moving.
So i need some help on :
- how to update the window scroll position based on the scroll bar position ?
- how to use ScrollWindow / ScrollWindowEx to scroll the contents of the window (cells...) ?
Thanks !
I have recently attempted to use the DetectScroll method developed by CPearson: http://www.cpearson.com/excel/DetectScroll.htm
It no longer works because it is based on the "WM_VSCROLL" messages, which I cannot find in any window's message stream using Spy++.
From this observation, I tried scrolling with Window's Messages and Window's API functions only
Let's assume we have these handles:
Code:
mainHwnd = Application.hWnd
dskHwnd = FindWindowEx(mainHwnd, 0, "XLDESK", vbNullString)
wbkHwnd = FindWindowEx(dskHwnd, 0, "EXCEL7", vbNullString)
sbVHwnd = FindWindowEx(wbkHwnd, 0, "NUIScrollbar", "Vertical")
The following does not work:
Code:
Private Type SCROLLINFO
cbSize As Long
fMask As Long
nMin As Long
nMax As Long
nPage As Long
nPos As Long
nTrackPos As Long
End Type
Private Const SIF_RANGE = &H1
Private Const SIF_PAGE = &H2
Private Const SIF_POS = &H4
Private Const SIF_DISABLENOSCROLL = &H8
Private Const SIF_TRACKPOS = &H10
Private Const SIF_ALL = (SIF_RANGE Or SIF_PAGE Or SIF_POS Or SIF_TRACKPOS)
Private Const SB_HORZ = 0
Private Const SB_VERT = 1
Private Const SB_CTL = 2
Private Const SB_LINEUP = 0
Private Const SB_LINEDOWN = 1
Private Const SB_THUMBPOSITION = 4
Dim lngRet As Long
Dim si As SCROLLINFO
With si
.cbSize = Len(si)
.fMask = SIF_ALL
lngRet = GetScrollInfo(wbkHwnd, SB_VERT, si)
.nPos = .nPos + 1
lngRet = SetScrollInfo(wbkHwnd, SB_VERT, si, True)
UpdateWindow wbkHwnd
End With
The following messages have not effect either:
Code:
SendMessage mainHwnd, WM_VSCROLL, SB_LINEDOWN, ByVal 0
SendMessage wbkHwnd, WM_VSCROLL, SB_LINEDOWN, ByVal 0
the "Workbook" window appears to no longer be responding to WM_VSCROLL messages. Spy++ also shows a child window of EXCEL7 of class "NUIScrollbar", which makes me think that the EXCEL7 window no longer uses a standard vertical scroll bar, but a custom control.
Now if I use the following, I get to successfully scroll the scrollbox of the scrollbar, but I fail to update the window's scroll based on the new position of the scrollbar:
Code:
lngRet = GetScrollInfo(sbVHwnd, SB_CTL, si)
.nPos = .nPos + 1
lngRet = SetScrollInfo(sbVHwnd, SB_CTL, si, True)
UpdateWindow wbkHwnd
I also noticed this message successfully moves the scrollbox AND the window:
Code:
'SendMessage wbkHwnd, WM_VSCROLL, SB_LINEDOWN, ByVal sbVHwnd
But I do not really like this last method since I cannot see this message in Spy++, so it is not how the system works natively...
I have also tried using the ScrollWindow and ScrollWindowEx functions to scroll the contents of the "Workbook" window, but I fail to see the cells moving.
So i need some help on :
- how to update the window scroll position based on the scroll bar position ?
- how to use ScrollWindow / ScrollWindowEx to scroll the contents of the window (cells...) ?
Thanks !
Last edited: