[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

detecting a vscrollbar in msflexgrid vb6

Posted on 2014-02-19
8
Medium Priority
?
251 Views
Last Modified: 2014-02-19
I am trying to set the width of a Msflexgrid based on if it has a vertical scrollbar
Code:
Const GWL_STYLE = (-16)
Const WS_VSCROLL = &H200000
Const WS_HSCROLL = &H100000
 
Private Declare Function GetWindowLong Lib "user32" _
    Alias "GetWindowLongA" ( _
        ByVal Hwnd As Long, _
        ByVal nIndex As Long) As Long
 
'==================================================================
Public Function IsHScrollVisible(Hwnd As Long) As Boolean
    Dim Style As Long
    Style = GetWindowLong(Hwnd, GWL_STYLE)
 
    If (Style And WS_HSCROLL) Then
        IsHScrollVisible = True
        Exit Function
    End If
 
End Function
 
'==================================================================
Public Function IsVScrollVisible(Hwnd As Long) As Boolean
    Dim Style As Long
    Style = GetWindowLong(Hwnd, GWL_STYLE)
 
    If (Style And WS_VSCROLL) Then
        IsVScrollVisible = True
        Exit Function
    End I
 
End Function
 



Sub PositionForm_Grid
gridStats.Width = 12184
       
  If IsVScrollVisible(gridStats.Hwnd) = False Then
    gridStats.Width = 11800 
  End If

Open in new window

The first time this Function is called it is false(this is correct)
The second time it reports true even though its not visible
Why is this ?
0
Comment
Question by:isnoend2001
[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
  • 4
  • 4
8 Comments
 
LVL 49

Expert Comment

by:Martin Liss
ID: 39871012
Try this in line 14

IsHScrollVisible = False
0
 
LVL 49

Expert Comment

by:Martin Liss
ID: 39871079
Actually it works fine as is for me so something else must be going on. Please attach your project in a zip file and tell me how to reproduce what you are seeing.
0
 

Author Comment

by:isnoend2001
ID: 39871336
Thanks martinLiss
I will upload the form as soon as i get it modified (Remove Ocx's etc)
The function is in a module
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:isnoend2001
ID: 39871614
martinLiss just click the button top left of form with caption '"Add text1 Rows"
will add the number of rows in text1 to grid
line 486 is the call
For-EE.zip
0
 

Author Comment

by:isnoend2001
ID: 39871791
This line is not always hit when false
 gridStats.Width = 11800 'shorten the width

 in Sub PositionForm_Grid()

If IsVScrollVisible(gridStats.HWND) = False Then
       gridStats.Width = 11800 'shorten the width
  End If

This works correctly
Private Sub Command2_Click()
MsgBox IsVScrollVisible(gridStats.HWND)
End Sub
0
 
LVL 49

Accepted Solution

by:
Martin Liss earned 2000 total points
ID: 39871794
I don't see the problem. Here's what happens when I click Command1.

First click:
1.    Rows are added
2.    Scrollbar is added because the grid is currently too short
3.    Because of that isVScrollVisible(gridStats.HWND) is True so the Width is not changed
4.    gridStats.Rows < iMax_Nu_Rows so the height is adjusted
5.    Because of that the scrollbar disappears

(The width should be adjusted at this point but it isn't)
Second click:
1.    The width is decreased because the scrollbar isn't visible.


Given what i've pointed out if you need any help correctly thge problem please let me know.
0
 

Author Closing Comment

by:isnoend2001
ID: 39871808
Thanks
Easy fix
0
 
LVL 49

Expert Comment

by:Martin Liss
ID: 39871824
You're welcome.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

649 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