Jump to content
Software FX Community

Re: Annotation objects and CurSel


Software FX

Recommended Posts

The problem is that you are getting a pointer to a IAnnTextPtr prior to

knowing if the object is in fact a Text object.

Here is the code that will work:

IAnnGroupPtr pGroup = pAnnList->CurSel; // The selection is ALWAYS a group

IAnnObjectPtr pObject;

IAnnTextPtr pText;

pText = NULL;

if (pGroup != NULL)

{

ObjectType type;

if (pGroup->Count != 0)

{

pObject = pGroup->Item(_variant_t((short)0)); // Get it in a GENERIC

object.

type = (ObjectType) (short) pObject->ObjectType;

if ((type == OBJECT_TYPE_TEXT) || (type != OBJECT_TYPE_BALLOON)) {

pText = pObject;

}

}

}

if (pText == NULL)

return 0;

pAnnList->ClearSelection();

return pText;

--

Frank

SFX

"Serge S. Spiridonoff" <sss@corbina.net> wrote in message

news:yxFukQcHAHA.1432@sfxserver.softwarefx.com...

> 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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...