scroll wheel & msflexgrid
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7

Thread: scroll wheel & msflexgrid

  1. #1
    Join Date
    Aug 2001
    Posts
    19

    scroll wheel & msflexgrid

    howdy,
    hopefully the last ever msflexgrid question from me....

    Anyone know how to implement a mouse scroll wheel with the flex grid ???

    thanx

    mat



  2. #2
    Join Date
    May 2000
    Location
    New York, NY, USA
    Posts
    2,878

    Re: scroll wheel & msflexgrid

    Here is API to scroll msfg

    WM_VSCROLL message to an MSFlexGrid control it moves the scrollbar and contents.

    private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (byval hwnd as Long, byval wMsg as Long, byval wParam as Long, lParam as Long) as Long


    private Const WM_VSCROLL = &h115

    'to scroll a grid upwards, wParam is 0
    public Sub ScrollGridUp(byval fg as MSFlexGrid)

    Dim lRet as Long

    lRet = SendMessage(fg.hwnd, WM_VSCROLL,0,0)

    End Sub


    'to scroll a grid down, wParam is 1
    public Sub ScrollGridDown(byval fg as MSFlexGrid)

    Dim lRet as Long

    lRet = SendMessage(fg.hwnd, WM_VSCROLL,1,0)

    End Sub


    Iouri Boutchkine
    iouri@hotsheet.com
    Iouri Boutchkine
    iouri@hotsheet.NOSPAM.com

  3. #3
    Join Date
    May 2000
    Location
    New York, NY, USA
    Posts
    2,878

    Re: scroll wheel & msflexgrid

    Her eis how to scroll using scroll bar

    MS Flex grid have scrollBars Property
    You can set design time or run time.


    With MSflecgrid1

    .ScrollBars = 0 or 1 0r 2 0r 3
    .row = rowlocation
    .col = collocation
    end with


    if value is 0 --None
    1 then Hoorizantal Scroll
    2 then Vertical
    3 is for both scrollbar


    or using TopRow

    You can set the TopRow property as in

    With MSflecgrid1
    .row = rowlocation
    .col = collocation
    .TopRow = rowlocation
    end with


    Iouri Boutchkine
    iouri@hotsheet.com
    Iouri Boutchkine
    iouri@hotsheet.NOSPAM.com

  4. #4
    Join Date
    Aug 2001
    Posts
    19

    Re: scroll wheel & msflexgrid

    thanx for getting back, thought it might need something that i couldn't understand :-)

    How do the subs get called ??

    I placed the code in there, but can't figure out the event that's meant to call them...

    cheerz for helping


  5. #5
    Join Date
    May 2000
    Location
    New York, NY, USA
    Posts
    2,878

    Re: scroll wheel & msflexgrid

    For the first post:
    Add Command1 button
    on command1_Click
    Call ScrollGridUp(MsFlexGrid1)


    for the second post put this code into Command1_Click

    With MSFlexGrid1

    .ScrollBars = 2 'vertical scroll
    .row = rowlocation
    .col = collocation
    end with


    Iouri Boutchkine
    iouri@hotsheet.com
    Iouri Boutchkine
    iouri@hotsheet.NOSPAM.com

  6. #6
    Join Date
    Aug 2001
    Posts
    19

    Re: scroll wheel & msflexgrid

    Yeh, i see how to call it like that, but i'm more after a situation like this...

    when the mouse is over the grid the wheel scrolls it vertically depending on direction of roll

    soooo....

    i need a method of testing continuously for wheel movement and trapping direction & if the mouse is over the grid......

    It's a tall order i think !!



  7. #7
    Join Date
    Jan 2017
    Posts
    10

    Re: scroll wheel & msflexgrid

    Here is an option I use that works pretty well. Its sort of a scroll/hot tracking effect where the grid automatically scrolls along with the Y position of the mouse. Works nicely.


    Code:
         Private Sub m_Grid_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
         On Error Resume Next
    
          With m_Grid
                Dim rowUnder As Integer:       rowUnder = (Y / .rowHeight(2)) - 1      ': Debug.Print rowUnder
               .TopRow = rowUnder
          End With
    
         End Sub

    If you would prefer to subclass instead the code required with examples can be downloaded at http://www.vb6.info/files/msflexgridwheelhook.zip

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)