User (Legacy) Posted September 13, 2000 Report Share Posted September 13, 2000 Hi! I am having troubles with detection of the currently selected annotation object. I use the following code to get the selection and check if it is a text box or a balloon. ******************** IAnnObjectPtr pCurSel = m_pAnnotationList->CurSel; IAnnGroupPtr pGroup; IAnnTextPtr pObject; if (pCurSel != NULL) { ObjectType type = (ObjectType)(short)pCurSel->ObjectType; if (type == OBJECT_TYPE_TEXT || type == OBJECT_TYPE_BALLOON) pObject = pCurSel; else if (type == OBJECT_TYPE_GROUP) { pGroup = pCurSel; if (pGroup->Count != 0) { pObject = pGroup->Item(_variant_t(long(0))); type = (ObjectType)(short)pObject->ObjectType; if (type != OBJECT_TYPE_TEXT && type != OBJECT_TYPE_BALLOON) pObject = NULL; } } } if (pObject == NULL) return; m_pAnnotationList->ClearSelection(); ... ******************** Sometimes it works but often it behaves strangely. 1) If I only have one text-box on the chart, CurSel usually returns an object of type OBJECT_TYPE_GROUP with Count property equal to 0. Why? What is wrong with the above code? 2) Also, ClearSelection usually causes Access violation, the call stack is: ANNOTATEX! 4400275c() ANNOTATEX! 44002387() Annotatex.dll 1.0.18.0 When is it safe to call ClearSelection? Thanks, Serge Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.