Start with the project you created in Vector Load and Save.
Take the following steps to add panning, selecting, and rotating capabilities:
In the project workspace, click on the Resource View tab and then click to open the "Tutorial resouces" branch.
Click to open the "Menu" branch and double click IDR_TutorialTYPE.
Add a menu item called "Tools" between the Edit and View items.
Create this Menu structure under the Tools Menu item:
&None with ID = ID_TOOLS_NONE
&Pan with ID = ID_TOOLS_PAN
&Select with ID = ID_TOOLS_SELECT
&Rotate with ID = ID_TOOLS_ROTATE
Select View->ClassView.
Right click on CTutorialDoc and select properties.
In the properties window select Events shortcut.
Select ID_TOOLS_NONE then COMMAND then add OnToolsNone
Repeat steps 5 6, and select ID_TOOLS_NONE then UPDATE_COMMAND_UI then add OnUpdateToolsNone
Repeat steps 5 through 9 for ID_TOOLS_PAN, ID_TOOLS_ROTATE, ID_TOOLS_SELECT.
Add the following code for the eight newly created functions:
void CTutorialDoc::OnToolsNone()
{
m_pVectorWindow->SetToolType (TOOL_VECTOR_USERMODE);
}
void CTutorialDoc::OnUpdateToolsNone(CCmdUI* pCmdUI)
{
pCmdUI->SetCheck (m_pVectorWindow->GetToolType () == TOOL_VECTOR_USERMODE);
}
void CTutorialDoc::OnToolsPan()
{
m_pVectorWindow->SetToolType (TOOL_VECTOR_PANIMAGE);
}
void CTutorialDoc::OnUpdateToolsPan(CCmdUI* pCmdUI)
{
pCmdUI->SetCheck(m_pVectorWindow->GetToolType () == TOOL_VECTOR_PANIMAGE);
}
void CTutorialDoc::OnToolsSelect()
{
m_pVectorWindow->SetToolType (TOOL_VECTOR_SELECT);
}
void CTutorialDoc::OnUpdateToolsSelect(CCmdUI* pCmdUI)
{
pCmdUI->SetCheck(m_pVectorWindow->GetToolType () == TOOL_VECTOR_SELECT);
}
void CTutorialDoc::OnToolsRotate()
{
m_pVectorWindow->SetToolType (TOOL_VECTOR_ROTATE);
}
void CTutorialDoc::OnUpdateToolsRotate(CCmdUI* pCmdUI)
{
pCmdUI->SetCheck(m_pVectorWindow->GetToolType () == TOOL_VECTOR_ROTATE);
}
Compile and run the program. Load an image. Hit the "+" key on the numeric keypad several times to zoom on the image. Select the Pan tool. A hand appears. Click anywhere on the image and drag. Now choose the Select tool. Click and drag on the image to select objects. Left-double click to select all objects. Right double-click to unselect all objects. Choose the Rotate tool. Left click and drag to rotate about the x and y axes. Right click and drag to rotate along the Z-axis.