在MapX中響應滾輪放大縮小地圖

來源:互聯網
上載者:User
放大|響應
’模組中

Option Explicit

Public Const GWL_WNDPROC = (-4)
Public Const WM_COMMAND = &H111
Public Const WM_MBUTTONDOWN = &H207
Public Const WM_MBUTTONUP = &H208
Public Const WM_MOUSEWHEEL = &H20A

Public Oldwinproc   As Long
Public Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Public 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
Public Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long) As Long

Public Function FlexScroll(ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
    Select Case wMsg
        Case WM_MOUSEWHEEL
            Select Case wParam
                Case -7864320     '向下滾
                    SetCurrentScale "ZoomOut", 2
                Case 7864320       '向上滾
                    SetCurrentScale "ZoomIn", 2
          End Select
    End Select
   
    FlexScroll = CallWindowProc(Oldwinproc, hWnd, wMsg, wParam, lParam)
End Function



Private Sub SetCurrentScale(strINorOut As String, dScale As Double)
    If frmMain.Map1 Is Nothing Then Exit Sub
   
    If strINorOut = "ZoomIn" Then
        frmMain.Map1.Zoom = (frmMain.Map1.Zoom) * dScale
        frmMain.Map1.Refresh
    ElseIf strINorOut = "ZoomOut" Then
        frmMain.Map1.Zoom = (frmMain.Map1.Zoom) / dScale
        frmMain.Map1.Refresh
    End If
End Sub







Private Sub Form_Load()
        
    Oldwinproc = GetWindowLong(Map1.hWnd, GWL_WNDPROC)
    SetWindowLong Map1.hWnd, GWL_WNDPROC, AddressOf FlexScroll

End Sub

Private Sub Form_Unload(Cancel As Integer)
    SetWindowLong Map1.hWnd, GWL_WNDPROC, Oldwinproc
End Sub




相關文章

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。