Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

GetScrollBarInfo API don't work

Status
Not open for further replies.

pieropingi

Programmer
Dec 2, 2011
4
CH
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
Dim SBInfo As WM_PSCROLLBARINFO

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
Private Const STATE_SYSTEM_UNAVAILABLE As Long = &H1
'for function WM_GetScrollBarInfo, WM_PSCROLLBARINFO structure is:
Type WM_PSCROLLBARINFO
cbSize As Long
rcScrollBar As WM_Rect
dxyLineButton As Integer
xyTumbTop As Integer
xyTumbBottom As Integer
reserved As Integer
rgState(CCHILDREN_SCROLLBAR + 1) As Long
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?
 
That simply says to me that it isn't a system scrollbar, just a custom control that looks like a scrollbar
 
Oh? The standard scrollbar of the very main access window? That would be odd! I get the window handle with Application.hWndAccessApp ...
 
so, strongm, that means you are confirming my code?

I have doubts about the value of the
Global Const OBJID_CLIENT As Long = &HFFFFFFFC
Global Const OBJID_HSCROLL As Long = &HFFFFFFFA
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
 
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)

So OBJID_CLIENT = -4 = &HFFFFFFFC

And your other OBJIDs are also correct



 
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.
 
I've looked more closely, and your primary problem is your declaration of WM_PSCROLLBARINFO which should be
Code:
Private Type WM_PSCROLLBARINFO
    cbSize As Long
    rcScrollBar As WM_RECT
    dxyLineButton As [b][red]Long[/red][/b]
    xyTumbTop As [b][red]Long[/red][/b]
    xyTumbBottom As [b][red]Long[/red][/b]
    reserved As [b][red]Long[/red][/b]
    rgState([b][red]0 To CCHILDREN_SCROLLBAR[/red][/b]) As Long
End Type
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top