Solved

Flexgrid scrollbars

Posted on 2002-05-24
3
936 Views
Last Modified: 2012-08-14
how can i know if the flexgrid is showing its vertical or horizontal scrollbar
0
Comment
Question by:pierrecampe
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 3

Expert Comment

by:Elmo_
ID: 7031638
Pierre,

I take it that you have set the ScrollBars Property to 3 - FlexScrollBarBoth and that you want to determine when which ones are showing.

Because the scroll bars automatically appear I would think you would need to calculate the Combined height of all the rows to determine if the Horitontal bar is showing and calculate the Combined Width of all the columns to determine if the Vertical scroll bar is showing.

You Could try this.  I have tested it and it works fine.

Private Sub Command1_Click()
Dim i As Integer
Dim Width As Integer
Dim Height As Integer

    i = 0
    For i = 0 To MSFG.Rows - 1
'        MSFG.Row = i
        Height = Height + MSFG.RowHeight(i)
    Next i
   
    i = 0
    For i = 0 To MSFG.Cols - 1
'        MSFG.Row = i
        Width = Width + MSFG.ColWidth(i)
    Next i
   
    If MSFG.Height < Height Then
        'Hozizontal scroll bar being displayed
        MsgBox Height & " - Horizontal Bar Being Displayed"
    End If
   
    If MSFG.Width < Width Then
        'Vertical scroll bar being displayed
        MsgBox Width & " - Vertical Bar Being Displayed"
    End If

End Sub


Cheers,

Ed.

0
 
LVL 43

Accepted Solution

by:
TimCottee earned 200 total points
ID: 7031654
Or you could use an API solution:

Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
Private Const GWL_STYLE = (-16)
Private Const WS_HSCROLL = &H100000
Private Const WS_VSCROLL = &H200000

Private Sub Command1_Click()
    Dim curstyle As Long
    curstyle = GetWindowLong(MSFlexGrid1.hwnd, GWL_STYLE)
    MsgBox "Vertical = " & ((curstyle Or WS_VSCROLL) = curstyle) & vbLf & "Horizontal = " & ((curstyle Or WS_HSCROLL) = curstyle)
End Sub
0
 
LVL 43

Expert Comment

by:TimCottee
ID: 7031670
You could wrap this into a sub like this to allow it to be used for any control that supports scrollbars:

Private Sub Command1_Click()
    Dim blnVertical As Boolean
    Dim blnHorizontal As Boolean
    WhichScrollbars MSFlexGrid1, blnVertical, blnHorizontal
    MsgBox "MSFlexGrid1 Has " & IIf(blnVertical And blnHorizontal, "Both Scrollbars", IIf(blnVertical And Not blnHorizontal, "Vertical Scrollbar", IIf(blnHorizontal And Not blnVertical, "Horizontal Scrollbar", "No Scrollbars")))
    WhichScrollbars Text1, blnVertical, blnHorizontal
    MsgBox "Text1 Has " & IIf(blnVertical And blnHorizontal, "Both Scrollbars", IIf(blnVertical And Not blnHorizontal, "Vertical Scrollbar", IIf(blnHorizontal And Not blnVertical, "Horizontal Scrollbar", "No Scrollbars")))
End Sub

Private Sub WhichScrollbars(ByRef CtrlToCheck As Object, ByRef Vertical As Boolean, ByRef Horizontal As Boolean)
    Dim lngCurStyle As Long
    lngCurStyle = GetWindowLong(CtrlToCheck.hwnd, GWL_STYLE)
    Vertical = ((lngCurStyle Or WS_VSCROLL) = lngCurStyle)
    Horizontal = ((lngCurStyle Or WS_HSCROLL) = lngCurStyle)
End Sub
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question