Previous Document Next Document

Understanding the CorelDRAW object model : Working with documents : Displaying documents


Displaying documents

You can simultaneously display multiple windows for a single document. For example, a large document can be displayed with one window zoomed in to the upper-right corner of the document and another zoomed in to the lower-right corner. Although the individual windows can be zoomed and panned independently, turning the page in one window affects all windows.

By using the View Manager, you can create views that have individual display settings. Choosing a saved view displays the page according to the settings for that view.

 
In VBA, the Window object provides access to the windows that contain each View object for (or view of) a given document. The Window object represents a frame, while the View object displays the document inside that frame.

Besides letting you work with windows and views, the application lets you display documents by zooming and panning.

Working with windows

Each Document object has a Windows collection for displaying that document. To switch between windows, use the Window.Activate method:

ActiveDocument.Windows(2).Activate

The Document.ActiveWindow property provides direct access to the active window — that is, the document window that is in front of all other document windows.

The next window and previous window for the active document are referenced in the Window.Next and Window.Previous properties:

ActiveWindow.Next.Activate

To create a new window, use the Window.NewWindow method:

ActiveWindow.NewWindow

To close a window (and the document, if it has only one open window), use the Window.Close method:

ActiveWindow.Close

If you want, you can use event handlers to respond to events that are triggered by activating a window:

 
Application.WindowActivate
 
GlobalMacroStorage.WindowActivate

You can also use event handlers to respond to events that are triggered by deactivating a window:

 
Application.WindowDeactivate
 
GlobalMacroStorage.WindowDeactivate
Working with views

The Window.ActiveView property and the Document.Views property both represent document views. Each Window object has one ActiveView object, which represents the current view of the document; saving the display settings for an ActiveView object creates a view. In contrast, each Document object has a collection of View objects in its Views property; choosing a View object activates the corresponding saved view, which contains the display settings for the corresponding ActiveView object.

 
The only way to access an ActiveView object is from the Window.ActiveView property.

You can create a View object and add it to a Document.Views collection. The following VBA code adds the current ActiveView settings to the Views collection:

ActiveDocument.Views.AddActiveView "New View"

You can also create a view with specific settings by using the Document.CreateView method. The following VBA code creates a new View object that accesses the position (3, 4) in inches, uses a zoom factor of 95%, and displays page 6:

ActiveDocument.Unit = cdrInch
ActiveDocument.CreateView "New View 2", 3, 4, 95, 6

To apply a saved view to the active window, call the View.Activate method:

ActiveDocument.Views("New View").Activate
Zooming

To zoom an ActiveView object by a set amount, set the ActiveView.Zoom property by specifying a double value in percent. For example, the following VBA code sets the zoom factor to 200%:

ActiveWindow.ActiveView.Zoom = 200.0

 
You can also zoom by using the following methods of the ActiveView class:
SetActualSize
ToFitAllObjects
ToFitArea
ToFitPage
ToFitPageHeight
ToFitPageWidth
ToFitSelection
ToFitShape
ToFitShapeRange
Panning

To pan an ActiveView object, you can move its origin by modifying the ActiveView.OriginX and ActiveView.OriginY properties. The following VBA code pans the document 5 inches to the left and 3 inches up:

Dim av As ActiveView
ActiveDocument.Unit = cdrInch
Set av = ActiveWindow.ActiveView
av.OriginX = av.OriginX - 5
av.OriginY = av.OriginY + 3

Alternatively, you can use the ActiveView.SetViewPoint method:

Dim av As ActiveView
ActiveDocument.Unit = cdrInch
Set av = ActiveWindow.ActiveView
av.SetViewPoint av.OriginX - 5, av.OriginY + 3

Previous Document Next Document Back to Top

Copyright 2013 Corel Corporation. All rights reserved.