SDK:Working with VWCustomCtrl

From Vectorworks Developer
Jump to navigation Jump to 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

Setup custom control in VWDialog

You need to create a class extending VWCustomCtrl

class CMyControl : public VWCustomCtrl
{
public:
                CMyControl(TControlID id);
  virtual       ~CMyControl();

// eventing
protected:
  virtual void  OnControlAttached();
  virtual void  OnPaint(VWCustomCtrlDC& dc);

// ...

};

Then you need to create an instance of your custom control in the VWDialog, and attach it to receive the events through DDX:

class CSampleDlg4 : public VWDialog
{
  // ...

// DDX
protected:
  fMyCustomCtrl1;

  // ...

};
CSampleDlg4::CSampleDlg4() :
    fMyCustomCtrl1( kMyCustomCtrlID ),
void CSampleDlg4::OnDDXInitialize()
{
  this->AddDDX_Control( & fMyCustomCtrl1 );
  // ...
}

Using tooltips

To use the tooltips you need to enable them and initialize the tooltip regions.

You should enable them after the control is created. This means in 'OnControlAttached' or subsequental events. By default tooltips are disabled.

You need to define tooltips in order to specify information for them. Tooltips are basicaly definition of the following struct:

struct SCustomCtrlToolTip
{
  TXString   fText;
  ViewRect   fRect;
  bool       fbTrackMouse;
  ViewPt     fPos;
};
  • fText -- the text that will appear when tooltip have to be shown;
  • fRect -- active region for the tooltip. When the cursor enters in this area it will show you the tooltip. The rectangle is in local coordinates of the custom control. By default it is set to empty, which means that this tooltip is for the entire region of the custom control;
  • fbTrackMouse -- true if you want the tooltip text to follow the mouse; false -- the tooltip will stay where it appears for the first time;
  • fPos -- Specify custom position of the tooltip; it will stay at this position as long as fbTrackMouse is false;


void CMyControl::OnControlAttached()
{
  this->EnableToolTips( true );

  SCustomCtrlToolTip	toolTip1;
  toolTip1.fText			= "this is my tool tip";
  toolTip1.fPos.Set( 10, 10 );
  this->AddToolTip( toolTip1 );

  SCustomCtrlToolTip	toolTip2;
  toolTip2.fText			= "region tool tip";
  toolTip2.fRect			= ViewRect( 15, 15, 55, 55 );
  toolTip2.fbTrackMouse	= true;
  this->AddToolTip( toolTip2 );

  SCustomCtrlToolTip	toolTip3;
  toolTip3.fText			= "another region tool tip";
  toolTip3.fRect			= ViewRect( 55, 15, 105, 55 );
  this->AddToolTip( toolTip3 );
}

There should be only one tooltip that has no 'fRect' defined.


See Also

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