Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. How to get the co-ordinates of rectangle

How to get the co-ordinates of rectangle

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestiongraphicsdockerjson
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    raju_shiva
    wrote on last edited by
    #1

    Hi all, I dnt know whether its a right forum for this question.If any one can help me it will be helpful to me. I am drawing a rectangle using LeadTools. Here is the code :

    void CImageViewerView::OnAnnotationRectanle()
    {
    m_ImageViewer.SetAction(CONTAINER_ACTION_ANNOTATION_RECTANGLE,CONTAINER_MOUSE_BUTTON_LEFT,FALSE);
    m_ImageViewer.EnableActionCallBack(TRUE);
    m_ImageViewer.SetAction(110, CONTAINER_MOUSE_BUTTON_RIGHT, DCACTION_ACTIVEONLY);
    }

    How can i get the co-ordinates 1) m_ImageViewer.SetAction : Sets the rectangle for left mouse button. 2)m_ImageViewer.EnableActionCallBack: Returns if the rectangle is drawn. 3)I want to use GetAnnotationContainer() for returning the co-ordinates.

    m_ImageViewer.SetAction(110, CONTAINER_MOUSE_BUTTON_RIGHT, DCACTION_ACTIVEONLY);

    This is working fine for me,I am changing the rectangle action to Right Mouse button

    Here is the API :
    L_INT GetAnnotationContainer(L_INT nCellIndex,L_INT nSubCellIndex,HANNOBJECT * PhAnnContainer,L_UINT uFlags);

    I have this in .h file

    typedef struct tagDISPCONTAINERCELLINFO
    {
    L_UINT uStructSize;
    L_HDC hDC;
    L_INT nCellIndex;
    L_INT nSubCellIndex;
    RECT rcRect;
    RECT rcBitmapRect;
    L_INT nX;
    L_INT nY;
    }
    DISPCONTAINERCELLINFO, * pDISPCONTAINERCELLINFO;

    When i am trying to use the same

    pDISPCONTAINERCELLINFO pCellInfo;

    void CImageViewerView::OnAnnotationRectanle()
    {
    m_ImageViewer.SetAction(CONTAINER_ACTION_ANNOTATION_RECTANGLE,CONTAINER_MOUSE_BUTTON_LEFT,FALSE);
    m_ImageViewer.EnableActionCallBack(TRUE);
    m_ImageViewer.SetAction(110, CONTAINER_MOUSE_BUTTON_RIGHT, DCACTION_ACTIVEONLY);
    m_ImageViewer.GetAnnotationContainer(pCellInfo->nCellIndex, pCellInfo->nSubCellIndex, &PhAnnContainer, CONTAINER_ACTION_ANNOTATION_RECTANGLE);
    }

    But i am getting memory cannot read for pCellInfo->nCellIndex (Run Time error) If any one knows what i am doing wrong,please help me Thanks raj

    S 1 Reply Last reply
    0
    • R raju_shiva

      Hi all, I dnt know whether its a right forum for this question.If any one can help me it will be helpful to me. I am drawing a rectangle using LeadTools. Here is the code :

      void CImageViewerView::OnAnnotationRectanle()
      {
      m_ImageViewer.SetAction(CONTAINER_ACTION_ANNOTATION_RECTANGLE,CONTAINER_MOUSE_BUTTON_LEFT,FALSE);
      m_ImageViewer.EnableActionCallBack(TRUE);
      m_ImageViewer.SetAction(110, CONTAINER_MOUSE_BUTTON_RIGHT, DCACTION_ACTIVEONLY);
      }

      How can i get the co-ordinates 1) m_ImageViewer.SetAction : Sets the rectangle for left mouse button. 2)m_ImageViewer.EnableActionCallBack: Returns if the rectangle is drawn. 3)I want to use GetAnnotationContainer() for returning the co-ordinates.

      m_ImageViewer.SetAction(110, CONTAINER_MOUSE_BUTTON_RIGHT, DCACTION_ACTIVEONLY);

      This is working fine for me,I am changing the rectangle action to Right Mouse button

      Here is the API :
      L_INT GetAnnotationContainer(L_INT nCellIndex,L_INT nSubCellIndex,HANNOBJECT * PhAnnContainer,L_UINT uFlags);

      I have this in .h file

      typedef struct tagDISPCONTAINERCELLINFO
      {
      L_UINT uStructSize;
      L_HDC hDC;
      L_INT nCellIndex;
      L_INT nSubCellIndex;
      RECT rcRect;
      RECT rcBitmapRect;
      L_INT nX;
      L_INT nY;
      }
      DISPCONTAINERCELLINFO, * pDISPCONTAINERCELLINFO;

      When i am trying to use the same

      pDISPCONTAINERCELLINFO pCellInfo;

      void CImageViewerView::OnAnnotationRectanle()
      {
      m_ImageViewer.SetAction(CONTAINER_ACTION_ANNOTATION_RECTANGLE,CONTAINER_MOUSE_BUTTON_LEFT,FALSE);
      m_ImageViewer.EnableActionCallBack(TRUE);
      m_ImageViewer.SetAction(110, CONTAINER_MOUSE_BUTTON_RIGHT, DCACTION_ACTIVEONLY);
      m_ImageViewer.GetAnnotationContainer(pCellInfo->nCellIndex, pCellInfo->nSubCellIndex, &PhAnnContainer, CONTAINER_ACTION_ANNOTATION_RECTANGLE);
      }

      But i am getting memory cannot read for pCellInfo->nCellIndex (Run Time error) If any one knows what i am doing wrong,please help me Thanks raj

      S Offline
      S Offline
      Stephen Hewitt
      wrote on last edited by
      #2

      You're accessing memory through an uninitialised pointer (pDISPCONTAINERCELLINFO pCellInfo;). In this situation the behaviour you're getting is exactly what's expected.

      Steve

      R 1 Reply Last reply
      0
      • S Stephen Hewitt

        You're accessing memory through an uninitialised pointer (pDISPCONTAINERCELLINFO pCellInfo;). In this situation the behaviour you're getting is exactly what's expected.

        Steve

        R Offline
        R Offline
        raju_shiva
        wrote on last edited by
        #3

        Hi, I corrected with

        DISPCONTAINERCELLINFO pCellInfo;
        m_ImageViewer.GetAnnotationContainer(pCellInfo->nCellIndex, pCellInfo->nSubCellIndex, &PhAnnContainer, CONTAINER_ACTION_ANNOTATION_RECTANGLE);

        But still i am no tgetting any coordinate values. Any idea will be helpful Thanks Raj

        S 1 Reply Last reply
        0
        • R raju_shiva

          Hi, I corrected with

          DISPCONTAINERCELLINFO pCellInfo;
          m_ImageViewer.GetAnnotationContainer(pCellInfo->nCellIndex, pCellInfo->nSubCellIndex, &PhAnnContainer, CONTAINER_ACTION_ANNOTATION_RECTANGLE);

          But still i am no tgetting any coordinate values. Any idea will be helpful Thanks Raj

          S Offline
          S Offline
          Stephen Hewitt
          wrote on last edited by
          #4

          Here's the API you gave in an earlier post:

          Here is the API :
          L_INT GetAnnotationContainer(L_INT nCellIndex,L_INT nSubCellIndex,HANNOBJECT * PhAnnContainer,L_UINT uFlags);

          I have this in .h file

          typedef struct tagDISPCONTAINERCELLINFO
          {
          L_UINT uStructSize;
          L_HDC hDC;
          L_INT nCellIndex;
          L_INT nSubCellIndex;
          RECT rcRect;
          RECT rcBitmapRect;
          L_INT nX;
          L_INT nY;
          }
          DISPCONTAINERCELLINFO, * pDISPCONTAINERCELLINFO;

          And here's the updated code you just posted (I've corrected the incorrect escaping):

          DISPCONTAINERCELLINFO pCellInfo;
          m_ImageViewer.GetAnnotationContainer(pCellInfo->nCellIndex, pCellInfo->nSubCellIndex, &PhAnnContainer, CONTAINER_ACTION_ANNOTATION_RECTANGLE);

          The pCellInfo variable is still not inititalised! In fact this code is worse, it will not even compile: pCellInfo is not a pointer (despite it's name suggesting it is) but is used as if it is (pCellInfo->nCellIndex).

          Steve

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups