OberonPlace.com Forums  

Go Back   OberonPlace.com Forums > Developer Forums > VBA > CorelDRAW/Corel DESIGNER VBA

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 23-01-2005, 23:04
jemmyell jemmyell is offline
Senior Member
 
Join Date: Jan 2005
Location: Orange County, California, USA, Earth, Solar System, Milky Way Galaxy
Posts: 157
Default ActiveView.OriginX is broken????

Hi All,

In the following UserForm Activate / Terminate events I have placed code to center a shape that I want to scale incrementally. All of my other operations work fine, but the property ActiveView.OriginX is simply wrong. For a default view, it should be 5.5 for a 8.5 x 11 document in landscape mode. Instead it is 7.54005905511811 which does NOT work well when I try to restore the original view origin as the UserForm is closed! Can anybody suggest a workaround to give me the REAL view X origin from VBA code??? The OriginY value is 4.25 which is correct.

Can anybody tell where to report this bug to Corel? I am running Draw 12 SP1.

-James Leonard

Option Explicit
Dim ZoomLevel As Integer
Dim OrigZoomLevel As Integer
Dim ViewOriginX As Double
Dim ViewOriginY As Double

Private Sub UserForm_Activate()

Dim X As Double
Dim Y As Double
Dim OrigX As Double
Dim OrigY As Double
Dim OrigWide As Double
Dim OrigHigh As Double
Dim VPXCenter As Double
Dim VPYCenter As Double

ViewOriginY = ActiveWindow.ActiveView.OriginY

ViewOriginX = ActiveWindow.ActiveView.OriginX

OrigZoomLevel = ActiveWindow.ActiveView.Zoom

ZoomLevel = OrigZoomLevel

ActiveSelection.Shapes(1).GetBoundingBox X, Y, OrigWide, OrigHigh

ActiveSelection.Shapes(1).GetPosition OrigX, OrigY

'Calculate the center of the shape

VPXCenter = OrigX + (OrigWide / 2)

VPYCenter = OrigY - (OrigHigh / 2)

'Set the viewpoint to the center of the active shape

ActiveWindow.ActiveView.SetViewPoint VPXCenter, VPYCenter, ZoomLevel

End Sub

Private Sub UserForm_Terminate()

ActiveWindow.ActiveView.SetViewPoint ViewOriginX, ViewOriginY, OrigZoomLevel

End Sub
Reply With Quote
  #2  
Old 24-01-2005, 00:03
Alex's Avatar
Alex Alex is offline
Administrator
 
Join Date: Nov 2002
Posts: 1,941
Blog Entries: 4
Default Re: ActiveView.OriginX is broken????

James,

Do you have any dockers open? It seems that saving/restoring the view works OK if no dockers are open...

But instead of fiddling with the view point center and zoom levels I would just save the current view in the View Manager and then restore it later. Here is the sample (I did simplify some of your code along the way ):

Code:
Option Explicit

Dim OrgView As View

Private Sub UserForm_Initialize()
    Dim OrigX As Double
    Dim OrigY As Double
    Dim OrigWide As Double
    Dim OrigHigh As Double
    Dim VPXCenter As Double
    Dim VPYCenter As Double
    
    Set OrgView = ActiveDocument.Views.AddActiveView("TempView")
    
    ActiveShape.GetBoundingBox OrigX, OrigY, OrigWide, OrigHigh
    
    'Calculate the center of the shape
    VPXCenter = OrigX + (OrigWide / 2)
    VPYCenter = OrigY + (OrigHigh / 2)
    
    'Set the viewpoint to the center of the active shape
    ActiveWindow.ActiveView.SetViewPoint VPXCenter, VPYCenter
End Sub

Private Sub UserForm_Terminate()
    ' Activate the saved view
    OrgView.Activate
    ' Delete from View Manager
    OrgView.Delete
    Set OrgView = Nothing
End Sub
I hope this helps
Reply With Quote
  #3  
Old 24-01-2005, 20:09
jemmyell jemmyell is offline
Senior Member
 
Join Date: Jan 2005
Location: Orange County, California, USA, Earth, Solar System, Milky Way Galaxy
Posts: 157
Default Thank you Alex, that does help!

Hi,

Yes, I always have the object properties docker open. The width of that docker is just right to explain the delta between what OriginX should be and actually is. Yes, saving and restoring the view will work very well. All I need to do is get back to where I was before invoking my custom scaling tool.

Thanks again,
__________________
-James Leonard
CNC Inlay Guy - www.CorelDRAWCadCam.com
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
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 On
HTML code is Off

Forum Jump


All times are GMT -5. The time now is 00:09.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2022, Jelsoft Enterprises Ltd.
Copyright © 2011, Oberonplace.com