ToolSelected Example VC++

In this example, when the ToolSelected event fires, all of the annotation tool names that appear in the Tools menu are unchecked.  (There is one menu item for each annotation tool in the Annotation Tool Palette.)

Then, according to the value of the ToolID parameter, the procedure checks the menu item that corresponds to the annotation tool selected by the user.

void CImgEdit2Dlg::OnToolSelected(short ToolId) 
{
    // Demonstrates using this event to keep menu selections in
    // sync with selections made from the Annotation Tool Palette
      
    // Initialize all menu selections to unchecked
    mnuToolsAnnoSelect.Checked = False;
    mnuToolsFreeLine.Checked = False;
    mnuToolsHighLine.Checked = False;
    mnuToolsStraightLine.Checked = False;
    mnuToolsHollowRect.Checked = False;
    mnuToolsFilledRect.Checked = False;
    mnuToolsText.Checked = False;
    mnuToolsNote.Checked = False;
    mnuToolsTextFile.Checked = False;
    mnuToolsStamp.Checked = False;
    mnuToolsHyperlinks.Checked = False;
    
    // Use the ToolId parameter to determine which tool
    // the user selected and then check the corresponding
    // menu item.
    switch (ToolId)
    {
      case 1:
        mnuToolsSelectArrow.Checked = True;
      case 2:
        mnuToolsSelectFreeLine.Checked = True;
      case 3:
        mnuToolsSelectHighLine.Checked = True;
      case 4:
        mnuToolsStraightLine.Checked = True;
      case 5:
        mnuToolsSelectHollowRect.Checked = True;
      case 6:
        mnuToolsSelectFilledRect.Checked = True;
      case 7:
        mnuToolsSelectText.Checked = True;
      case 8:
        mnuToolsSelectNote.Checked = True;
      case 9:
        mnuToolsSelectTextFile.Checked = True;
      case 10:
        mnuToolsSelectStamp.Checked = True;
      case 11:
        mnuToolsSelectHyperlinks.Checked = True;
    }
}