CorelDRAW Macro UI Controls and Dialog Boxes
Automating workflows in CorelDRAW often requires user interaction to collect parameters, confirm actions, or display data. By leveraging Visual Basic for Applications (VBA) or the Visual Studio Tools for Applications (VSTA) framework, developers can integrate a variety of user interface (UI) controls into their macros. These range from simple system prompts to complex, multi-page dialog windows and custom workspace dockers.
Built-in System Dialogs
For simple scripts that require minimal interaction, CorelDRAW's VBA engine provides lightweight, built-in dialog functions that do not require building custom forms:
- MsgBox: Displays alert messages, errors, or simple prompts with standard buttons such as OK, Cancel, Yes, No, and Retry. It returns the user's selection to branch code execution.
- InputBox: Prompts the user with a single-line text field to retrieve strings, numbers, or dimensions directly without creating a dedicated interface.
- CorelDRAW File Dialogs: Accesses the native
application file browser (
CorelScript.GetFileBoxor system file dialogs) to let users locate, open, or save files.
Custom Dialog Boxes (UserForms)
When a macro requires multiple inputs, developers use a UserForm. A UserForm acts as a custom dialog box container where developers can drop and configure standard UI controls:
- CommandButton: Standard push-buttons used to trigger subroutines, such as "Apply," "Cancel," or "Generate."
- TextBox: Single-line or multi-line editable fields that collect text, coordinates, scale factors, or custom values.
- Label: Static text elements used to display instructions, descriptions, or real-time output.
- ComboBox: A drop-down menu combining a text box and a list, ideal for selecting presets, color palettes, or CorelDRAW layer names.
- ListBox: A scrollable list allowing single or multiple selections, commonly used for choosing specific shapes, pages, or document objects.
- CheckBox: Toggle boxes allowing independent on/off or true/false selections, such as toggling "Preserve Aspect Ratio" or "Group Objects."
- OptionButton (Radio Button): Mutually exclusive selection controls grouped inside a container, used for selecting one choice out of many, such as alignment positions (Left, Center, Right).
- Frame: A visual and logical container used to group related controls (such as a cluster of OptionButtons) together.
- MultiPage and TabStrip: Tabbed containers used to organize complex macro settings into separate tabs, keeping the dialog window compact.
- SpinButton and ScrollBar: Incremental controls allowing users to adjust numeric properties, such as object sizes, rotations, or copies, by clicking up/down arrows or dragging a slider.
- Image Control: A display area for icons, visual previews, or diagrams within the macro form.
Advanced Controls and Dockers
Beyond standard VBA UserForms, CorelDRAW supports advanced UI integration through its .NET/VSTA API and C++ SDK:
- Custom Dockers: Using .NET (C# or VB.NET) with Windows Presentation Foundation (WPF) or WinForms, developers can build custom dockable palettes that integrate directly into CorelDRAW’s main workspace alongside native dockers.
- ActiveX Controls: VBA UserForms can host external ActiveX controls (such as Common Dialog controls, TreeView, or ProgressBar) if registered on the host system.
- Custom Toolbars and Menus: Macros can be mapped to custom buttons, flyouts, and menu entries on CorelDRAW’s native command bars, providing direct entry points into custom dialog boxes.