Developers can add an annotation object to an image programmatically or with user interaction. The user can use the mouse to create new annotation objects and place them on the image. The user can move, resize, or delete annotation objects. Developers have to redefine mouse event handler functions to create new annotation objects with the mouse.
[C++]
#include “BiAnno.h”
#include “BiDisp.h”
void CMyView::OnLButtonDown(UINT nFlags, CPoint point)
{
…
::SetCapture( m_hWnd );
POINT pt;
pt.x = point.x;
pt.y = point.y;
CDC * pDC = GetDC();
MapDisplayDC(pDC->m_hDC, lpDisp);
pDC->DPtoLP( &pt, 1);
// lAnno is the annotation handle
if(AnnoUIOnLButtonDown ( lAnno, pDC->m_hDC, nFlags, pt ) )
UpdateSelectionRect();
ReleaseDC(pDC);
…
}
void CMyView::OnMouseMove(UINT nFlags, CPoint point)
{
…
POINT pt;
pt.x = point.x;
pt.y = point.y;
CDC * pDC = GetDC();
MapDisplayDC(pDC->m_hDC, lpDisp);
pDC->DPtoLP( &pt, 1);
// lAnno is the annotation handle
AnnoUIOnMouseMove (lAnno, pDC->m_hDC, nFlags, pt );
ReleaseDC(pDC);
…
}
void CMyView::OnLButtonUp(UINT nFlags, CPoint point)
{
…
::ReleaseCapture();
POINT pt;
pt.x = point.x;
pt.y = point.y;
CDC * pDC = GetDC();
MapDisplayDC(pDC->m_hDC, lpDisp);
pDC->DPtoLP( &pt, 1);
// lAnno is the annotation handle
if(AnnoUIOnLButtonUp(lAnno, pDC->m_hDC, nFlags, pt ) )
UpdateSelectionRect();
ReleaseDC(pDC);
…
}
You can call the AnnoUISetNewObject function to create a new annotation object, and use the mouse to place the newly created object on the image.
[VB]
Private Sub BiDisp_MouseDown(Button As Integer, Shift As Integer, X As Single, y As Single)
Dim hDC As Long
Dim Left As Long
Dim Top As Long
Dim Right As Long
Dim Bottom As Long
Dim ret As Boolean
…
BiDisp.SetCapture
hDC = BiDisp.GetDC
ret = BiAnno.OnMouseDown(hDC, Button, Shift, BiDisp.MouseX, _
BiDisp.MouseY)
If ret = True Then
Anno.AnnoUIGetUpdateRect Left, Top, Right, Bottom
BiDisp.UpdateControl Left, Top, Right, Bottom
End If
…
End Sub
Private Sub BiDisp_MouseMove(Button As Integer, Shift As Integer, X As Single, y As Single)
Dim ret As Boolean
Dim hDC As Long
…
hDC = BiDisp.GetDC
ret = Anno.OnMouseMove(hDC, Button, Shift, BiDisp.MouseX, _
BiDisp.MouseY)
BiDisp.ReleaseDC (hDC)
…
End Sub
Private Sub BiDisp_MouseUp(Button As Integer, Shift As Integer, X As Single, y As Single)
Dim ret As Boolean
Dim hDC As Long
Dim Left As Long
Dim Top As Long
Dim Right As Long
Dim Bottom As Long
…
hDC = BlackIce1.GetDC
BiDisp.ReleaseCapture
ret = Anno.OnMouseUp(hDC, Button, Shift, BiDisp.MouseX, _
BiDisp.MouseY)
BiDisp.ReleaseDC (hDC)
If ret = True Then
Anno.AnnoUIGetUpdateRect Left, Top, Right, Bottom
BiDisp.UpdateControl Left, Top, Right, Bottom
End If
…
End Sub
You can call the AnnoUISetNewObject method to create a new annotation object, and use the mouse to place the newly created object on the image.
[C#]
private void BiDisp_MouseDownEvent(object sender, AxBIDISPLib._DBIDispEvents_MouseDownEvent e)
{
…
BiDisp.SetCapture();
int hDC = BiDisp.GetDC();
int Left = 0, Right = 0, Top = 0, Bottom = 0;
bool ret = BiAnno.OnMouseDown(hDC, e.button, e.shift, BiDisp.MouseX,
BiDisp.MouseY);
BiDisp.ReleaseDC(hDC);
if (ret)
{
BiAnno.AnnoUIGetUpdateRect(ref Left, ref Top, ref Right, ref Bottom);
BiDisp.UpdateControl(Left, Top, Right, Bottom);
}
…
}
private void BiDisp_MouseMoveEvent(object sender, AxBIDISPLib._DBIDispEvents_MouseMoveEvent e)
{
…
int hDC = BiDisp.GetDC();
BiAnno.OnMouseMove(hDC, e.button, e.shift, BiDisp.MouseX, BiDisp.MouseY);
BiDisp.ReleaseDC(hDC);
…
}
private void BiDisp_MouseUpEvent(object sender, AxBIDISPLib._DBIDispEvents_MouseUpEvent e)
{
…
bool ret = false;
BiDisp.ReleaseCapture();
ret = BiAnno.OnMouseUp(hDC, e.button, e.shift, BiDisp.MouseX,
BiDisp.MouseY);
BiDisp.ReleaseDC(hDC);
if (ret)
{
BiAnno.AnnoUIGetUpdateRect(ref Left, ref Top, ref Right, ref Bottom);
BiDisp.UpdateControl(Left, Top, Right, Bottom);
}
…
}
You can call the AnnoUISetNewObject method to create a new annotation object, and use the mouse to place the newly created object on the image.