Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here


GetScrollBarInfo API don't work

GetScrollBarInfo API don't work

GetScrollBarInfo API don't work

Hi all,

Somebody has a running example of GetScrollBarInfo API ? With my code, I get no results and a dll error 87.

I'm trying to know if the scrollbars (in my case, the horizontal scrollbar) are showed in the main access window. I use GetScrollBarInfo. There are 2 days I'm, searching info about the function and the parameters, but they are hard to find.
I can only find general descriptions of the API.
I found some constant values in the ApiViewer 2004.

Here is my API-calling code (in a form class-module):

'vede se la scroll bar orizzontale è visibile
Dim void As Integer

SBInfo.cbSize = Len(SBInfo)
void = WM_GetScrollBarInfo(Application.hWndAccessApp, OBJID_HSCROLL, SBInfo)

Debug.Print SBInfo.rgState(0)

After the API call:
- no error message is given. err.number is 0
- void is 0 (function not succeeded?)
- the err.LastDllError contains 87 (invalid parm?)
- all components of SBInfo are = to 0

Here are the declarations I'm using:

Type WM_Rect
Left As Long
Top As Long
Width As Long
Height As Long
End Type

'Declare Function WM_GetScrollBarInfo
'for function WM_GetScrollBarInfo, param IDObject can be:
Global Const OBJID_CLIENT As Long = &HFFFFFFFC 'the hwnd parm is a handle to a scroll bar control
Global Const OBJID_HSCROLL As Long = &HFFFFFFFA 'the horizontal scroll bar of the hwnd window
Global Const OBJID_VSCROLL As Long = &HFFFFFFFB 'the vertical scroll bar of the hwnd window
'for function WM_GetScrollBarInfo - type WM_PSCROLLBARINFO - rgState param
Global Const CCHILDREN_SCROLLBAR As Long = 5
'necessary to give a dimention to the rgState array in WM_PSCROLLBARINFO
'the 5 index of the array indicate:
'0 = The scrollbar itself
'1 = The top or right arrow button
'2 = The page up or page right region
'3 = The scroll box (thumb)
'4 = The page down or page left region
'5 = The bottom of left arrow button
'every indication can contains (can be combined?):
Private Const STATE_SYSTEM_INVISIBLE As Long = &H8000
Private Const STATE_SYSTEM_OFFSCREEN As Long = &H10000
Private Const STATE_SYSTEM_PRESSED As Long = &H8
'for function WM_GetScrollBarInfo, WM_PSCROLLBARINFO structure is:
cbSize As Long
rcScrollBar As WM_Rect
dxyLineButton As Integer
xyTumbTop As Integer
xyTumbBottom As Integer
reserved As Integer
End Type
Declare Function WM_GetScrollBarInfo Lib "user32.dll" Alias "GetScrollBarInfo" (ByVal hwnd As Long, ByVal idObject As Long, ByRef psbi As WM_PSCROLLBARINFO) As Long

Some hint?

RE: GetScrollBarInfo API don't work

That simply says to me that it isn't a system scrollbar, just a custom control that looks like a scrollbar

RE: GetScrollBarInfo API don't work

Oh? The standard scrollbar of the very main access window? That would be odd! I get the window handle with Application.hWndAccessApp ...

RE: GetScrollBarInfo API don't work

so, strongm, that means you are confirming my code?

I have doubts about the value of the
Global Const OBJID_VSCROLL As Long = &HFFFFFFFB constants.

I found that in C++ examples, but I don't know the needed decimal values. Access tell me OBJID_HSCROLL is -6. Is that correct?
Calculator tell me &HFFFFFFFA = 4'294'967'290 . Why?

Thanks for the intrest

RE: GetScrollBarInfo API don't work

It is to do with represebtation

Signed Long integers are 4 bytes in length in VB and C (Calc by default uses a different number of bytes for integer representation so, unless you are clear about what you are foing, do not use Calc to compare resuolts)

And in those log integers, -4 is represented as FF FF FF FC using two's complement (top bit set to indicate negative, invert all the rest of the bits of the positive representation of the number and then add 1)


And your other OBJIDs are also correct


RE: GetScrollBarInfo API don't work

When in Windows Calculator, you switch to Hex mode, it selects the word size to Qword (Quad word) by default which has a storage spece of 64 bits. So the number FFFFFFFA is actually treated as 00000000FFFFFFFA (64 bits) and its decimal equivalent turns out to be 4,294,967,290 as you see.

If you set the word size to Dword (which is 32 bits long, like a Long data type), the hex number FFFFFFFA will be treated as a 32 bit number and its decimal equivalent be -6 as explained by strongm.

RE: GetScrollBarInfo API don't work

I've looked more closely, and your primary problem is your declaration of WM_PSCROLLBARINFO which should be


    cbSize As Long
    rcScrollBar As WM_RECT
    dxyLineButton As Long
    xyTumbTop As Long
    xyTumbBottom As Long
    reserved As Long
    rgState(0 To CCHILDREN_SCROLLBAR) As Long
End Type

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close