AnnGetGrouping example for Delphi

//This example will toggle the grouping feature for all
//the sub-containers
//This event is fired for each annotation
//Toggles the Grouping feature for all the containers
procedure TForm1.LEADAnn1AnnEnumerate (hObject: L_HANDLE);
begin
if ( LEADAnn1.AnnGetType (hObject)= ANNOBJECT_CONTAINER ) then
     LEADAnn1.AnnSetGrouping ( hObject, 
                 not LEADAnn1.AnnGetGrouping (hObject),0 ) ;
end;

//Add sub-containers by selecting objects and grouping them
//before clicking on this button
//Note that after you disable the grouping you can select and change
//individual objects belonging to a group. When you re-enable
//the grouping, the objects act as a group again.
procedure TForm1.Button1Click(Sender: TObject);
begin
   LEADAnn1.AnnUserMode:= ANNUSERMODE_DESIGN;
   LEADAnn1.AnnEnumerate (LEADAnn1.AnnContainer, ANNFLAG_RECURSE + ANNFLAG_NOTTHIS, Nil);
end;