Grouping and Ungrouping Annotation Objects
Note: This topic is for Document/Medical only.
If more than one object is selected when the right mouse button is pressed, the "Group" menu option appears and lets you group the selected objects. From that moment on, all the grouped objects are acted on as one in automation mode. When you select one object, all objects become selected. When you unselect an object belonging to a group, all objects in that group are unselected.
To select only one object in a group, you must ungroup them. When you select a "grouped" set of objects and press the right mouse button, the "Ungroup" option appears in the menu. Selecting that option "ungroups" the objects. After that, objects are independent (you can select one without selecting the others).
Each container has a "Grouping" feature, which determines whether the objects contained in that container are treated as a group by the automation. If the "Grouping" feature is TRUE, then all the objects in the container should be treated as a group. If the "Grouping" feature is FALSE, then the objects in the container can be selected and changed independently. The "Grouping" feature of a container can be set using the AnnSetGrouping method. To determine the status of the "Grouping" feature of a container, call the AnnGetGrouping method.
The AnnGroup method does the following:
creates a sub-container
moves the objects to this sub-container
sets the Grouping feature for the sub-container to TRUE
Setting the Grouping feature to FALSE by calling the AnnSetGrouping method with bAutoGroup set to FALSE is similar to calling the AnnUngroup method.
To change only one object within a group, do the following:
find the object's container.
set the grouping property to FALSE for the container.
change the object.
set the grouping feature to TRUE for the container.
To programmatically move all the objects belonging to a group you have two choices:
1. Move the subcontainer, which contains all the objects (not the best solution)
2. Move all the objects present in that container (the better solution).
The problem with moving the container is that objects are clipped to their container. So if the subcontainer has an offset of 100 and you try to move the objects in the automated mode, then you cannot move the objects all the way to the left. You will be able to move the objects in the automated mode, but their left side will disappear.
This means that if you are going to use subcontainers and automated mode at the same time, then you should create the subcontainers so that they have the same size as the main container. Or, you can keep track of the mouse notifications. And move the subcontainer whenever the mouse moves.
To create a group of objects, you can create a container, insert all the objects in it and insert that container in the main container (without stripping the container).