Previous Document Next Document

Getting started with macros : Using the Macro Editor : Using the Object Browser


Using the Object Browser

The Object Browser is one of the most useful tools that is provided by the Macro Editor. In an easy-to-use, structured format, the Object Browser displays the entire object model of each referenced component and, most importantly, of CorelDRAW.

 
Referenced components include all ActiveX or Object Linking and Embedding (OLE) objects that are used by the project.

The Object Browser window features the following items:

 
Project/Library list box — lists all referenced components (projects and libraries). Choosing a project or library from this list updates the Object Browser to display only the items for that project or library. Generally, displaying only one project or library at a time makes it easier to use the Object Browser.
 
navigation buttons — let you cycle through your selections from the Object Browser
 
Copy to Clipboard button — copies the current selection to the Clipboard
 
View Definition button — displays where the current selection is defined in the Code window
 
Help button — displays a Help topic for the current selection. You can also access this Help topic by pressing F1.
 
search controls — let you search the selected project or library for a given string. For more information, see Using the search controls.
 
Search Results window — displays the results of a search. For more information, see Using the search controls.
 
Class list — displays all class-related items for the selected project or library. For more information, see Using the Class list.
 
Member list — displays the members of the selected class. For more information, see Using the Member list.
 
Information window — displays information about the selected class or class member. For more information, see Using the Information window.

The Object Browser window (Corel PHOTO-PAINT version shown)

To open the Object Browser from within the Macro Editor, do any of the following:

 
Click View } Object Browser.
 
Click the Object Browser button on the Standard toolbar.
 
Press F2.

 
To reference the object model of another application, click Tools } References. Referenced components can be accessed by the macro code.
Using the Class list

Every project and library has an object model that contains the following class-related items, which are displayed in the Class list:

 
global values
 
classes
 
modules
 
types
 
enumerations

Global values apply to an entire project or library, and they include individual members from enumerations (such as text-paragraph alignments, shape types, and import/export filters).

Classes contain properties, methods, and events. For more information, see What is a class?.

 
For documentation on all classes available to CorelDRAW, see Classes.

Modules contain macro code.

 
For documentation on all modules available to CorelDRAW, see Modules.

Types are customized data types that supplement the built-in data types that are provided by the automation environment (see Declaring variables).

 
For documentation on all types available to CorelDRAW, see Types.

Enumerations represent fixed values in the procedures and functions of the coding for a macro. For more information, see What is an enumeration?.

 
For documentation on all enumerations available to CorelDRAW, see Enumerations.

Each type of item in the Class list has an icon assigned to it:

Icon
Item
global value
class
module
type
enumeration

 
To access the Help topic for a selected item, click the Help button, or press F1.
Using the Member list

When you choose an item from the Class list, the members of that item appear in the Member list. Class members include the following:

 
properties
 
methods
 
events
 
constants

A property can be a simple type (such as a Boolean, integer, or string), or it can be a class or enumeration from the Class list. A property that is based on a class from the Class list inherits all members of that class.

Many classes have a default property. The default property is implied if no property name is given when getting or setting the value of the parent object. For example, collection types have the default property Item, which can be indexed; in such instances, it is not necessary to specify the Item property. Here,

ActiveSelection.Shapes.Item(1).Selected = False

is the same as the shorter

ActiveSelection.Shapes(1).Selected = False

because Item is the default or implied property of a collection of shapes.

 
For documentation on all properties available to CorelDRAW, see Properties.

Methods are commonly known as “member functions” — functions that a class can perform on itself. A good example is the Move method of the Shape class, which moves a shape by using an [x, y] vector. The following code moves the selected shapes 2 measurement units to the right and 3 measurement units upwards:

ActiveSelection.Move 2, 3

If the return value of a function is not used, the function call does not take parentheses around the argument list unless the Call keyword is used.

 
For documentation on all methods available to CorelDRAW, see Methods.

Events are associated with some classes. You can set up an event handler that is called when that event occurs in the application; this functionality lets you develop sophisticated applications that respond automatically to what is happening within the application. Commonly handled events include the BeforePrint, BeforeSave, PageActivate, SelectionChange, and ShapeMove events of the Document class.

 
For documentation on all events available to CorelDRAW, see Events.

The constants displayed in the Member list are members of enumerations or are defined as public in a module. Enumerations group related items from a closed list — such as shape types, import/export filters, and alignments — for use anywhere an integer value is required.

In CorelDRAW, many constants begin with cdr (for example, cdrEPS and cdrLeftAlignment), while others begin with clr, pdf, pnt, or prn. Visual Basic also has its own constants, including ones (such as vbKeyEnter) for keystrokes and ones (such as vbOK) for dialog-box buttons.

 
For documentation on all constants available to CorelDRAW, see Constants.

Each type of item in the Member list has an icon assigned to it:

Icon
Item
property
default property
method
event
constant

 
To access the Help topic for a selected item, click the Help button, or press F1.
Using the Information window

The Information window provides information about the selected class or class member. This information includes the following:

 
a prototype of the item
 
an indication of whether the item is a read-only property
 
the parent of the item
 
a short description of the item

The Information window for the Document.Application property in Corel PHOTO-PAINT

The Information window provides hyperlinks to all referenced types and classes that are defined within the current object model. For example, the information for the Document.Application property in Corel PHOTO-PAINT (see the preceding figure) includes the following hyperlinks:

 
Application — accesses the Application class, because Application is both the type of the Document.Application property and a class in the PHOTOPAINT library
 
PHOTOPAINT — accesses the class for the PHOTOPAINT library, which contains all classes in the Corel PHOTO-PAINT object model
 
Document — accesses the Document class, which is the parent of the Application property

 
When the Information window is not tall enough to reveal its complete contents, a scroll bar is provided. To increase the height of the Information window, drag the top border of the window upwards.
Using the search controls

The search controls let you search the selected project or library for a given string. Searching is useful when you can only partly remember the name of a class or class member, or when you want to find classes and members that have similar names (such as those containing the word “open”).

Searching the CorelDRAW object model

To search the classes and members of the selected object model, type a string into the Search box, and then click the Search button . The Search Results window displays, in alphabetical order, all matches. Clicking a match advances the Class list and Member list to that item and displays the Information window for that item.

 
Matching class names have a blank Member column in the Search Results window.

 
To hide the Search Results window, click the Hide Search Results button .

Previous Document Next Document Back to Top

Copyright 2013 Corel Corporation. All rights reserved.