AnnDefine2 example for C++ 5 and later
//'This example uses static variables to simulate user input to
//'rotate/resize a rectangle around a point on the bottom center line of the rectangle
//'Intially the rectangle must not be rotated.
void CTutorDlg::ExampleAnnDefine2(long hObject)
{
long hContainer ;
AnnObjectType ObjectType ;
double Angle ;
long CallCount=0;
double RectTop ;
double RectLeft ;
double RectWidth ;
double RectHeight;
double RectRight ;
double RectBottom;
double AnchorX ;
double AnchorY;
double MoveX;
double MoveY;
double AnnPointX;
double AnnPointY;
m_pRasterAnn->AnnGetType (hObject);
ObjectType = m_pRasterAnn->GetAnnType();
if (ObjectType != ANN_OBJECT_RECT )
MessageBox (TEXT("This Object is not Rect Object"));
Angle = m_pRasterAnn->GetAnnRotateAngle(hObject);
if (Angle != 0 )
MessageBox (TEXT("Object must not be rotated"));
CallCount = CallCount + 1;
switch (CallCount)
{
case 1:
RectTop = m_pRasterAnn->GetAnnRectTop(hObject);
RectLeft = m_pRasterAnn->GetAnnRectLeft(hObject);
RectWidth = m_pRasterAnn->GetAnnRectWidth(hObject);
RectHeight = m_pRasterAnn->GetAnnRectHeight(hObject);
RectRight = RectWidth + RectLeft;
RectBottom = RectHeight + RectTop;
AnchorX = (RectLeft + RectRight) / 2;
AnchorY = RectBottom;
AnnPointX = (RectLeft + RectRight) / 2;
AnnPointY = RectTop;
m_pRasterAnn->AnnDefine2(hObject, AnchorX, AnchorY, ANN_DEFINE_SETANCHORPOINT);
m_pRasterAnn->AnnDefine2(hObject, AnnPointX, AnnPointY, ANN_DEFINE_BEGINMOVEPOINT);
case 2:
RectTop = m_pRasterAnn->GetAnnRectTop(hObject);
RectLeft = m_pRasterAnn->GetAnnRectLeft(hObject);
RectWidth = m_pRasterAnn->GetAnnRectWidth(hObject);
RectHeight = m_pRasterAnn->GetAnnRectHeight(hObject);
RectRight = RectWidth + RectLeft;
RectBottom = RectHeight + RectTop;
m_pRasterAnn->PointsCount = 1;
m_pRasterAnn->ContainerPointX = RectRight;
m_pRasterAnn->ContainerPointY = RectTop;
hContainer = m_pRasterAnn->AnnGetContainer(hObject);
m_pRasterAnn->AnnConvert(hContainer, ANN_CONVERT_TO_CLIENT);
m_pRasterAnn->PointIndex = 0;
MoveX = m_pRasterAnn->ClientPointX;
MoveY = m_pRasterAnn->ClientPointY;
m_pRasterAnn->AnnDefine2(hObject, MoveX, MoveY, ANN_DEFINE_END);
CallCount = 0;
}
}