AutoCAD VBA MSFlexGrid Mouse Scroll
AutoCAD VBA MSFlexGrid Mouse Scroll
AutoCAD VBA MSFlexGrid Mouse Scroll
AutoCAD VBA MSFlexGrid Mouse Scroll
AutoCAD VBA MSFlexGrid Mouse Scroll
AutoCAD VBA MSFlexGrid Mouse Scroll AutoCAD VBA MSFlexGrid Mouse Scroll AutoCAD VBA MSFlexGrid Mouse Scroll AutoCAD VBA MSFlexGrid Mouse Scroll AutoCAD VBA MSFlexGrid Mouse Scroll AutoCAD VBA MSFlexGrid Mouse Scroll AutoCAD VBA MSFlexGrid Mouse Scroll AutoCAD VBA MSFlexGrid Mouse Scroll
AutoCAD VBA MSFlexGrid Mouse Scroll AutoCAD VBA MSFlexGrid Mouse Scroll
AutoCAD VBA MSFlexGrid Mouse Scroll
Go Back  Xtreme Visual Basic Talk > > > > AutoCAD VBA MSFlexGrid Mouse Scroll


Reply
 
Thread Tools Display Modes
  #1  
Old 01-18-2015, 11:32 AM
geodou geodou is offline
Newcomer
 
Join Date: Jan 2015
Posts: 2
Default AutoCAD VBA MSFlexGrid Mouse Scroll


Hi to everyone. I have a form with an MSFlexGrid. I can't get my mouse wheel scroll in the grid. I use a code from VB6 but it doesn't work. I am submitting the code below:
Code In Module:

Private Declare Function CallWindowProc Lib "user32.dll" 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 Declare Function SetWindowLong Lib "user32.dll" Alias "SetWindowLongA" ( _
ByVal hWnd As Long, _
ByVal nIndex As Long, _
ByVal dwNewLong As Long) As Long

Public Const MK_CONTROL = &H8
Public Const MK_LBUTTON = &H1
Public Const MK_RBUTTON = &H2
Public Const MK_MBUTTON = &H10
Public Const MK_SHIFT = &H4
Private Const GWL_WNDPROC = -4
Private Const WM_MOUSEWHEEL = &H20A

Dim LocalHwnd As Long
Dim LocalPrevWndProc As Long
Dim MyForm As UserForm
Dim MyGrid As MSFlexGrid
Private hControl As Long

Private Function WindowProc(ByVal Lwnd As Long, ByVal Lmsg As Long, ByVal Wparam As Long, ByVal Lparam As Long) As Long

Dim MouseKeys As Long
Dim Rotation As Long
Dim Xpos As Long
Dim Ypos As Long

If Lmsg = WM_MOUSEWHEEL Then
MouseKeys = Wparam And 65535
Rotation = Wparam / 65536
Xpos = Lparam And 65535
Ypos = Lparam / 65536
MouseWheel MouseKeys, Rotation, Xpos, Ypos, MyGrid
End If

WindowProc = CallWindowProc(LocalPrevWndProc, Lwnd, Lmsg, Wparam, Lparam)

End Function
Public Sub WheelHook(PassedForm As UserForm, PassedFlexGrid As MSFlexGrid)

On Error Resume Next

Set MyForm = PassedForm
LocalHwnd = PassedForm.hWnd

Set MyGrid = PassedFlexGrid
LocalPrevWndProc = SetWindowLong(LocalHwnd, GWL_WNDPROC, AddressOf WindowProc)
End Sub
Public Sub WheelUnHook()
Dim WorkFlag As Long

On Error Resume Next
WorkFlag = SetWindowLong(LocalHwnd, GWL_WNDPROC, LocalPrevWndProc)
Set MyForm = Nothing
End Sub
Public Sub MouseWheel(ByVal MouseKeys As Long, ByVal Rotation As Long, ByVal Xpos As Long, ByVal Ypos As Long, MyGrid As MSFlexGrid)
Dim NewValue As Long
Dim Lstep As Single

On Error Resume Next

With MyGrid
Lstep = .Height / .RowHeight(0)
Lstep = Int(Lstep)
If Lstep < 10 Then
Lstep = 10
End If
If Rotation > 0 Then
NewValue = .TopRow - Lstep
If NewValue < 1 Then
NewValue = 1
End If
Else
NewValue = .TopRow + Lstep
If NewValue > .Rows - 1 Then
NewValue = .Rows - 1
End If
End If
.TopRow = NewValue
End With
End Sub
Code In The Form:

Private Sub msgr_01_Click()
WheelUnHook
WheelHook msgr_01
End Sub

Any ideas or suggestions?
Thanks in advance.

Last edited by geodou; 01-18-2015 at 12:42 PM.
Reply With Quote
  #2  
Old 01-18-2015, 10:22 PM
Gruff's Avatar
GruffAutoCAD VBA MSFlexGrid Mouse Scroll Gruff is offline
Bald Mountain Survivor

Retired Moderator
* Expert *
 
Join Date: Aug 2003
Location: Oregon, USA - deceased
Posts: 6,440
Default

What version of Acad are you using? Is this running on a 64 bit machine?

Autodesk supports VBA7 32 & 64 bit. Any windows Api routines will have to be rewritten for 64 bit with new keywords and datatypes that support 64 bit. PtrSafe, PtrLong, longlong, Etc...

VBA7 from Microsoft.

In any case I would imagine that the MshFlexgrid would have issues running in such an environment.

You might want to try asking this question on the Autodesk AutoCad VBA cusomization Forum
__________________
Burn the land and boil the sea
You can't take the sky from me


~T

Last edited by Gruff; 01-18-2015 at 10:32 PM.
Reply With Quote
  #3  
Old 01-19-2015, 02:12 AM
geodou geodou is offline
Newcomer
 
Join Date: Jan 2015
Posts: 2
Default

Exactly Gruff. I use Autocad 2011 x64. I will try the Autodesk AutoCad VBA cusomization Forum. Thanks for your reply.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
AutoCAD VBA MSFlexGrid Mouse Scroll
AutoCAD VBA MSFlexGrid Mouse Scroll
AutoCAD VBA MSFlexGrid Mouse Scroll AutoCAD VBA MSFlexGrid Mouse Scroll
AutoCAD VBA MSFlexGrid Mouse Scroll
AutoCAD VBA MSFlexGrid Mouse Scroll
AutoCAD VBA MSFlexGrid Mouse Scroll AutoCAD VBA MSFlexGrid Mouse Scroll AutoCAD VBA MSFlexGrid Mouse Scroll AutoCAD VBA MSFlexGrid Mouse Scroll AutoCAD VBA MSFlexGrid Mouse Scroll AutoCAD VBA MSFlexGrid Mouse Scroll AutoCAD VBA MSFlexGrid Mouse Scroll
AutoCAD VBA MSFlexGrid Mouse Scroll
AutoCAD VBA MSFlexGrid Mouse Scroll
 
AutoCAD VBA MSFlexGrid Mouse Scroll
AutoCAD VBA MSFlexGrid Mouse Scroll
 
-->