控制ms访问滚动条的连续forms

我正在实施一个连续的拖放模拟。

基本上它的工作方式是,有一列人在旁边,用户可以将一个人从列表拖动到一个字段(这是一个座位列表,其中有Seat1,Seat2,seat3 …等字段)座位排是新的logging)。

对于基本的拖放function,我使用这个链接的拖放指令,它工作得很好。

现在这里是我的问题 ,要知道用户在哪个logging上移动鼠标我需要计算鼠标的细分部分的位置,所以虽然窗体不向下滚动它工作良好,但是当forms是向下滚动,我首先需要知道表单是多less,这只能通过一个Windows API来完成。

所以我发现www.lebans.com/conformscurcontrol.htm正好有我需要的代码,但是这只能在ms访问的旧版本中工作,在新版本中打破的代码是,他正在检查窗口类名称“滚动条”,并调用GetScrollInfo API,但在新版本中没有名为“滚动条”的类,但还有一个名为NUIScrollbar的类请参阅此处 ,但即使将其更改为此名称,我也不会回来一个有效的滚动条类(LPSCROLLINFO)。

这里是Stephen Lebans的代码

Public Function fGetScrollBarPos(frm As Form) As Long ' Return ScrollBar Thumb position ' for the Vertical Scrollbar attached to the ' Form passed to this Function. Dim hWndSB As Long Dim lngRet As Long Dim sinfo As SCROLLINFO ' Init SCROLLINFO structure sinfo.fMask = SIF_ALL sinfo.cbSize = Len(sinfo) sinfo.nPos = 0 sinfo.nTrackPos = 0 ' Call function to get handle to ' ScrollBar control if it is visible hWndSB = fIsScrollBar(frm) If hWndSB = -1 Then fGetScrollBarPos = False Exit Function End If ' Get the window's ScrollBar position lngRet = apiGetScrollInfo(hWndSB, SB_CTL, sinfo) 'Debug.Print "nPos:" & sInfo.nPos & " nPage:" & sInfo.nPage & " nMax:" & sInfo.nMax fGetScrollBarPos = sinfo.nPos + 1 End Function Private Function fIsScrollBar(frm As Form) As Long ' Get ScrollBar's hWnd Dim hWnd_VSB As Long Dim hWnd As Long hWnd = frm.hWnd ' Let's get first Child Window of the FORM hWnd_VSB = apiGetWindow(hWnd, GW_CHILD) ' Let's walk through every sibling window of the Form Do ' Thanks to Terry Kreft for explaining ' why the apiGetParent acll is not required. ' Terry is in a Class by himself! :-) 'If apiGetParent(hWnd_VSB) <> hWnd Then Exit Do 

这旧的和平

  If fGetClassName(hWnd_VSB) = "scrollBar" Then If apiGetWindowLong(hWnd_VSB, GWL_STYLE) And SBS_VERT Then fIsScrollBar = hWnd_VSB Exit Function End If End If 

这是我试图取代它

  If fGetClassName(hWnd_VSB) = "NUIScrollbar" Then If apiGetWindowLong(hWnd_VSB, GWL_STYLE) And 1107296256 Then fIsScrollBar = hWnd_VSB Exit Function End If End If 

继续function

  ' Let's get the NEXT SIBLING Window hWnd_VSB = apiGetWindow(hWnd_VSB, GW_HWNDNEXT) ' Let's Start the process from the Top again ' Really just an error check Loop While hWnd_VSB <> 0 ' SORRY - NO Vertical ScrollBar control ' is currently visible for this Form fIsScrollBar = -1 End Function ' From Dev Ashish's Site ' The Access Web ' http://www.mvps.org/access/ '******* Code Start ********* Private Function fGetClassName(hWnd As Long) Dim strBuffer As String Dim lngLen As Long Const MAX_LEN = 255 strBuffer = Space$(MAX_LEN) lngLen = apiGetClassName(hWnd, strBuffer, MAX_LEN) If lngLen > 0 Then fGetClassName = Left$(strBuffer, lngLen) End Function '******* Code End ********* 

希望我很清楚,任何帮助表示赞赏。

得到了同样的问题,以下似乎工作:

 Public Const SB_HORZ As Long = 0 ' &H0 (32 bit) Public Const SB_VERT As Long = 1 ' &H1 (32 bit) Public Const SB_CTL As Long = 2 Public Const SB_BOTH As Long = 3 Public Const SB_HORZ64_0 As Long = 1107296256 ' &H42000000 (64 bit - invisible) Public Const SB_VERT64_0 As Long = 1107296257 ' &H42000001 (64 bit - invisible) Public Const SB_HORZ64_1 As Long = 1375731712 ' &H52000000 (64 bit - visible) Public Const SB_VERT64_1 As Long = 1375731713 ' &H52000001 (64 bit - visible) ... eWindowStyle = GetWindowLong(ehWnd, GWL_STYLE) Select Case eWindowStyle Case SB_HORZ, SB_HORZ64_0, SB_HORZ64_1 ' *** Horizontal wWinAPIhWndScrollbarHorz = ehWnd Case SB_VERT, SB_VERT64_0, SB_VERT64_1 ' *** Vertikal wWinAPIhWndScrollbarVert = ehWnd End Select ...