SDK:Creating handler class for VectorScript layout dialog

From Vectorworks Developer
Jump to: navigation, search

.SDK|SDK ..SDK:Types|SDK Types ..SDK:Using the SDK|Using the SDK ..VCOM:VCOM (Vectorworks Component Object Model)|VCOM Basics ..VCOM:Class Reference|VCOM Class Reference

Dialog handler

The first thing to do is to create a VectorScript that creates the desired dialog. The best way to do is to use Dialog Builder.

Then you should put the text of the script in DialogLayout section in your resource file (vwr file), and give it unique name for the resource file.

The only difference for this dialog from the manual layout dialogs is that you create the dialog not control by control, but telling Vectorworks to call the script which creates the dialog.

Here is an example of what a dialog should look like:

// The MyDialog.h file
class CMyDialog : public VW::VWUI::VWDialog
    virtual      ~CMyDialog();

    virtual bool  CreateDialogLayout();

// events dispatcher map
    void          EditIntegerChanged(long controlID, VWDialogEventArgs eventArg);

    virtual void  OnSetUpEvent();
    virtual void  OnDDXInitialize();
    virtual void  OnUpdateUI();

// DDX variables
    long          fIntControlValue;

// Inner data

// The MyDialog.cpp file
#include "MyDialog.h"
#define    kTextControlID          3
#define    kEditIntegerControlID   4

using namespace VW::VWUI; 

ADD_DISPATCH_EVENT( kEditIntegerControlID, EditIntegerChanged );

     // TODO: Init DDX variables -- if any


bool CMyDialog::CreateDialogLayout()
    return this->CreateDialogLayoutFromVWR( "ResourceFile/DialogLayout/Layout.vs" ) )

void CMyDialog::OnSetUpEvent()

void CMyDialog::OnDDXInitialize()
    // TODO: Attach DDX variables -- if any
    this->AddDDX_EditInteger( kEditIntegerControlID, & fIntControlValue );

void CMyDialog::OnUpdateUI()

    // TODO: Update user interface state

void CMyDialog::EditIntegerChanged(long controlID, VWDialogEventArgs eventArg)
    // TODO: Handle the control event
Call VWDialog::CreateDilaogLayoutFromVWR function
This is the function which actually creates the dialog. Any user of this dialog will create and instance of the class, and call this function to actually create the dialog and all controls inside. The function should return true if everything is ok with creation.
Here you tell the VectorWorks to create the dialog from DialogLayout resource passing the name of the resource. In this example "ResourceFile/DialogLayout/Layout.vs" is the path of the VS resource containing the VectorScript creating the dialog.
  • Creating dispatch map
By using DEFINE_EVENT_DISPATH_MAP macros in the class definition you add the message dispatching mechanism to your dialog. You also have to implement the map in your cpp file with the macros: EVENT_DISPATCH_MAP_BEGIN and EVENT_DISPATCH_MAP_END. Within these two, you should add dispatcher entries, which message id and which function should be called.
  • Add dispatch event for the controls
By using ADD_DISPATCH_EVENT macros, you specify which function should be called, when event for specified control ID appears.
In the example above, a function is assigned to the event for the integer control, and that is the event when the controls was changed.
This function is called when the dialog is already created but not shown. This is the place where you SHOULD initialize your control content, hide controls and so on.
This function is called when the dialog should be updated. That happens when any control in the dialog layout is changed.
This is the place where normally you enable/disable, show/hide controls in the dialog layout.
This function is part of the Dynamic Data Exchange (DDX) mechanism. This mechanism provides you a simple way of putting values into the controls and getting it out of there.
This function is called before the dialog is show, and it should bind the concrete variables of the class with the controls in the dialog.

Running the dialog:

CMyDialog	dlg;
if ( dlg.RunDialogLayout() == VW::VWUI::kDialogButton_Ok ) {
   // TODO: Do something usefull

See Also

SDK:Creating handler class for manual layout dialog | SDK:Working with Dynamic Data Exchange (DDX) | Using Saved Settings |

Personal tools

Advanced Search
See Also