Setting Vector Automation Properties

Start with the project you created in 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"

  13. 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); 
    } 

  14. Compile and run the demo.

  15. Choose View->Vector Toolbar.

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

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

Help Version 22.0.2022.12.7
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.

LEADTOOLS Container and Automation C++ Class Library Help
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.