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:
Click on the "Resource View" tab of the project workspace.
Click to open the "VecAut resources" branch.
Click to open the "Menu" branch.
Double click "IDR_MAINFRAME".
Add a menu item "Preferences".
Drag the menu item to appear after "Edit" and before "View".
Add another menu item under "Preferences" called "Color..."
Right click on "Color" and choose "Add Event Handler"
For "Class name" select "CVecAutApp".
For "Object IDs" select "ID_PREFERENCES_COLOR".
For "Messages" select "COMMAND".
Click the "Add and Edit"
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);
}
Compile and run the demo.
Choose View->Vector Toolbar.
Choose Preferences->Color and select a color from the color picker dialog.
Select the Line tool from the Vector Toolbar and draw a line. It will be in the color that you selected.