Setting Vector Automation Properties

Start with the project you created in Tutorial3: The Automation Container.

Take the following steps to add the capability to change to color of the vector objects created with automation:

1.

Click on the "Resource View" tab of the project workspace.

2.

Click to open the "VecAut resources" branch.

3.

Click to open the "Menu" branch.

4.

Double click "IDR_MAINFRAME".

5.

Add a menu item "Preferences".

6.

Drag the menu item to appear after "Edit" and before "View".

7.

Add another menu item under "Preferences" called "Color..."

8.

Right click on "Color" and choose "Add Event Handler"

9.

For "Class name" select "CVecAutApp".

10.

For "Object IDs" select "ID_PREFERENCES_COLOR".

11.

For "Messages" select "COMMAND".

12.

Click the "Add and Edit"

14.

Add the following code:

void CVecAutApp::OnPreferencesColor() 
{ 
   AUTOMATIONVECTORPROPERTIES AutVecProps; 
    
   //Get current automation PEN properties 
   AutVecProps.nSize = sizeof(AUTOMATIONVECTORPROPERTIES); 
   AutVecProps.dwMask = AUTOMATION_VECTOR_PEN; 
   m_Automation.GetVectorProperty (&AutVecProps); 
    
   //Display color picker dialog to select new color 
   CColorDialog dlg; 
   dlg.m_cc.Flags |= CC_FULLOPEN | CC_RGBINIT; 
   dlg.m_cc.rgbResult = AutVecProps.Pen.NewPen.LogPen.lopnColor; 
    
   if (IDOK  == dlg.DoModal()) 
   { 
      AutVecProps.Pen.bExtPen = FALSE; 
      AutVecProps.Pen.NewPen.LogPen.lopnColor = dlg.GetColor(); 
   } 
    
   m_Automation.SetVectorProperty (&AutVecProps); 
} 

15.

Compile and run the demo.

16.

Choose View->Vector Toolbar.

17.

Choose Preferences->Color and select a color from the color picker dialog.

18.

Select the Line tool from the Vector Toolbar and draw a line. It will be in the color that you selected.

Help Version 19.0.2017.10.27
Products | Support | Contact Us | Copyright Notices
© 1991-2017 LEAD Technologies, Inc. All Rights Reserved.
LEADTOOLS Container and Automation C++ Class Library Help