| |

VerySource

 Forgot password?
 Register
Search
View: 989|Reply: 6

The form controls used in the project are all msflexgrid, but now customers require the form to support the scroll wheel

[Copy link]

1

Threads

9

Posts

6.00

Credits

Newbie

Rank: 1

Credits
6.00

 China

Post time: 2020-1-5 13:10:01
| Show all posts |Read mode
No third-party table controls are used in my project, they are all built-in msflexgrid, but this control does not support the mouse wheel. Now how can the customer make this request?
It must be impossible to replace the table control. A lot of work. I just want to find a way to use msflexgrid.
Please help me.
Reply

Use magic Report

0

Threads

3

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

Post time: 2020-1-5 17:57:01
| Show all posts
1, HOOK, there are codes online, ready-made.
PS: If you can't find it, you can buy it from me.

2. For the other, the ListView report type is recommended.
Reply

Use magic Report

1

Threads

9

Posts

6.00

Credits

Newbie

Rank: 1

Credits
6.00

 China

 Author| Post time: 2020-1-6 06:45:01
| Show all posts
2. For the other, the ListView report type is recommended.
-----------------------
Oh, but listview is not a real table after all. I also thought of using it.

Ranch

1, HOOK, there are codes online, ready-made.
---------------
I haven't found it yet. I found a few codes, but the test failed. Look again.
Reply

Use magic Report

1

Threads

6

Posts

6.00

Credits

Newbie

Rank: 1

Credits
6.00

 China

Post time: 2020-1-8 09:00:02
| Show all posts
There is code available ...
If you can't find it, find me ...
Reply

Use magic Report

2

Threads

5

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

Post time: 2020-1-8 11:18:01
| Show all posts
Please post the code online and share it with everyone, thank you.
Reply

Use magic Report

0

Threads

8

Posts

9.00

Credits

Newbie

Rank: 1

Credits
9.00

 China

Post time: 2020-3-29 16:45:01
| Show all posts
The following program is placed in a common module,
HookWheel me.hwnd in the form_load event of the form
UnHookWheel me.hwnd in the form_unload event in the form
In the GotFocus event of the form, set CtlWheel = MSFlexGrid1 '(the name of the form, modify this name according to the specific situation)

Set CtlWheel = Nothing 'in the LostFocus event of the form (the name of the form, modify this name according to the specific situation)


Option Explicit

Private Declare Function SetWindowLong Lib "user32" Alias ​​"SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private Declare Function CallWindowProc Lib "user32" Alias ​​"CallWindowProcA" (ByVal lpPrevWndFunc As Long, ByVal hwnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long

Private Const GWL_WNDPROC As Long = (-4)
Private Const WM_MOUSEWHEEL As Long =&H20A


Private m_OldWindowProc As Long

Public CtlWheel As Object

Public Sub HookWheel (ByVal frmHwnd)

    m_OldWindowProc = SetWindowLong (frmHwnd, GWL_WNDPROC, AddressOf pvWindowProc)
End Sub

Public Sub UnHookWheel (ByVal hwnd As Long)
    Dim lngReturnValue As Long
    lngReturnValue = SetWindowLong (hwnd, GWL_WNDPROC, m_OldWindowProc)
    
End Sub

Private Function pvWindowProc (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
    On Error GoTo errH
    
    Select Case wMsg
    
        Case WM_MOUSEWHEEL
            If Not CtlWheel Is Nothing Then
                 If TypeOf CtlWheel Is MSFlexGrid Then
                     With CtlWheel
                    
                             Select Case wParam
                             Case Is> 0
        
                                If CtlWheel.TopRow> 0 Then
                                    CtlWheel.TopRow = CtlWheel.TopRow-1
                                End If
                                
                             Case Else
                               
                                CtlWheel.TopRow = CtlWheel.TopRow + 1
                                
                             End Select
                      End With
                  End If
                  
           End If
    End Select
    
errH:
    
    pvWindowProc = CallWindowProc (m_OldWindowProc, hwnd, wMsg, wParam, lParam)
End Function
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-8-21 07:00:01
| Show all posts
Created a new project to test your code, it runs normally, thank you very much

After adding these codes to one of my programs, it runs normally. But when I press F5 to execute in the VB environment, once the program is closed, not only the program is closed, but also the VB is closed~~What's the matter? ? (This will not happen when I build a new project to test)
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list