Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic How to get extent of visible view (Read 3170 times)
Dirk Woelfel
Guest


How to get extent of visible view
Jul 3rd, 2006 at 10:24am
Print Post  
Hello,

how can I get the extent of the visible view. The aim is to implement an own "ZoomToRectangle" method, which zooms at the middle of the current view and not at the top-left-corner  - so I have to know the current extent of view.

Thanks,

Dirk
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: How to get extent of visible view
Reply #1 - Jul 3rd, 2006 at 11:23am
Print Post  
Hi,

You can use the ClientPtToDocPt method to find the logical coordinates of a pixel. E.g. this method should zoom into the center of the view by adding 10 to the zoom factor:

[code]
Private Sub cmdZoom_Click()
Dim widthPixels As Single
Dim heightPixels As Single

widthPixels = ScaleX(fcx.Width, vbTwips, vbPixels)
heightPixels = ScaleY(fcx.Height, vbTwips, vbPixels)

Dim centerBeforeZoomX As Long
Dim centerBeforeZoomY As Long

fcx.ClientPtToDocPt widthPixels / 2, heightPixels / 2, _
centerBeforeZoomX, centerBeforeZoomY

fcx.ZoomFactor = fcx.ZoomFactor + 10

Dim centerAfterZoomX As Long
Dim centerAfterZoomY As Long

fcx.ClientPtToDocPt widthPixels / 2, heightPixels / 2, _
centerAfterZoomX, centerAfterZoomY

'this restores the center point
fcx.ScrollX = fcx.ScrollX + centerBeforeZoomX - centerAfterZoomX
fcx.ScrollY = fcx.ScrollY + centerBeforeZoomY - centerAfterZoomY
End Sub
[/code]

Convert (0,0) and (widthPixels, heightPixels) to find out what the view rectangle is in document coordinates.

Stoyan
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint