|Title||Make a map that shows a circular closeup of the part under the mouse in Visual Basic 6|
|Description||This example shows how to make a map that shows a circular closeup of the part under the mouse in Visual Basic 6.|
|Keywords||closeup map, map, enlarge, closeup, close up, Visual Basic 6|
The program stores an enlarged version of the map in the hidden PictureBox picHidden. When the mouse moves, the program copies part of that image over the smaller image that is visible, giving a closeup of the area under the mouse.
The program defines some constants that control how big an area is enlarged and the scale factor.
When the mouse moves, the program clears the visible PictureBox. That PictureBox's AutoRedraw property is set to True at design time so this restores its original picture.
The program then uses the BeginPath and EndPath API functions to make a path out of the circle that defines the closeup area. It uses SelectClipPath to restrict drawing on the PictureBox to that region and then copies a piece of the big map onto the small visible one. It finsihes by drawing a circle to outline the closeup. It draws the circle with line width 3 because the clipping path crops out some of the circle's edge.
Private Const SCALE_FACTOR As Integer = 2
Private Const SMALL_RADIUS As Integer = 25
Private Const BIG_RADIUS As Integer = SMALL_RADIUS * _
Private Const BIG_DIAMETER As Integer = 2 * BIG_RADIUS
Private Declare Function SelectClipPath Lib "gdi32" (ByVal _
hdc As Long, ByVal iMode As Long) As Long
Private Declare Function BeginPath Lib "gdi32" (ByVal hdc _
As Long) As Long
Private Declare Function EndPath Lib "gdi32" (ByVal hdc As _
Long) As Long
Private Const RGN_COPY = 5
Private Sub Form_Load()
picMap.ScaleMode = vbPixels
Private Sub picMap_MouseMove(Button As Integer, Shift As _
Integer, X As Single, Y As Single)
' Restore the original small map.
' Draw a chunk of the big picture on top.
picMap.PaintPicture picHidden.Picture, _
X - BIG_RADIUS, Y - BIG_RADIUS, BIG_DIAMETER, _
X * 2 - BIG_RADIUS, Y * 2 - BIG_RADIUS, _
' Outline the closeup.
picMap.Line (X - BIG_RADIUS, Y - _
BIG_RADIUS)-Step(BIG_DIAMETER, BIG_DIAMETER), _