Select to view content in your preferred language

Map scale change event??

2496
1
06-26-2010 01:51 AM
AbdulrahmanAlqasim
Emerging Contributor
in my application, i need to know the event of map scale change. for example, once the user change the map scale , message appear with current map scale.

how i can detect this event ??
thank you
0 Kudos
1 Reply
WilliamChristmas
Deactivated User
You can use the following code.  Set TransEvent to activate the listener.  I did this in Sub SetListener_On, but you could do it on form load.  Anyway after you set TransEvent every time the map scale changes the code will display your message box.  To deactivate the listener, set TransEvent = nothing.

Private WithEvents TransEvent As DisplayTransformation

Public Sub SetListener_On()
    Dim pMxDoc As IMxDocument
    Set pMxDoc = Application.Document
    Set TransEvent = pMxDoc.ActiveView.ScreenDisplay.DisplayTransformation
End Sub

Private Sub TransEvent_VisibleBoundsUpdated(ByVal sender As IDisplayTransformation, ByVal sizeChanged As Boolean)
    If sizeChanged Then
        Dim pmxdocument As IMxDocument
        Dim pMap As IMap
        Set pMxDoc = Application.Document
        Set pMap = pMxDoc.FocusMap
        MsgBox "Map Scale = " & pMap.MapScale
    End If
End Sub
0 Kudos