Line tracker class similar to CRectTracker

Line tracker class (KLineTracker) that I present here performs dragging and resizing of lines with left mouse button. It does for lines the same thing CRectTracker does for rectangles.

When I needed to add to my application possibility to draw, move and resize lines using mouse, I looked for line tracker class in MFC. Because I used CRectTracker for resizing and moving rectangles, I expected to see CLineTracker for moving and resizing lines. But unfortunately I did not find one. Then I went to the Internet (Deja News, Alta Vista, InfoSeek, etc.), but they did not give me the answer too. The only thing I saw were requests for line tracker class from other people.

In the end, I decided to write line tracker class myself. I choose name KLineTracker instead of CLineTracker, so that if CLineTracker class will be sometimes added to MFC, my program will not run into clash.

Usage of the class is very similar to that of CRectTracker. Details should be obvious from the demo project (look at TrackerWnd.cpp). Suggessions for changes, improvements and bug reports are welcome. Although, I don't promise to fix all the bugs fast :-).

Download demo project - 42 KB

Download source - 4 KB



Comments

  • How can I use it with CScrollView?

    Posted by Legacy on 06/18/2003 12:00am

    Originally posted by: Tran Cong Khanh

    KLineTracker class is great!. But it doesn't care about scrolling. So when using it with CScollView, what additional code I must add?

    Reply
  • i thik KLineTracker can be created dynamically.

    Posted by Legacy on 01/20/2002 12:00am

    Originally posted by: JinSoo

    Hello!!! Ivan.

    My name is JinSoo.

    I am Korean. I am now using your KLineTracker From CodeGuru.

    when i create dynamically the KLineTracker , A Strange thing occured.

    and when i also delete the KLineTracker. An Error occured.

    i thik KLineTracker can be created dynamically.

    I hope you thai i can create and delete dynamically the KLineTracker.

    please, have a nice day. and Good Answer !!!

    Reply
  • Would't it be great if it was resizable ?

    Posted by Legacy on 07/21/1999 12:00am

    Originally posted by: George Sgouros

    First of all congratulations to Ivan for this excellent
    piece of code.

    I only have a request :

    I really need this control to be resizable.
    If the control had something like an OnSize handler
    AND it could use the client area of a Static control,
    then I guess everything would not be so difficult
    (I could use cdxCSizingDialog classes (described elswhere in Code Guru ) to resize the static control and hopefully
    the line tracker control should resize as well.

    However , being a newbie, I cannot yet add this functionality on my own.

    To be more specific :
    1. I cannot make TrackerWnd use the client area of a static control that is binded with a CStatic variable (I get an assertion during subclassing. CStatic variable declaration is necessary for using cdx... resizing classes)

    2. I do not know what exactly should I write inside the OnSize() handler.

    So, any suggestions on this issues would be highly appreciated.

    Best regards

    George

    Reply
  • BUG: when input canceled, temp rubber line stays visible

    Posted by Legacy on 06/22/1999 12:00am

    Originally posted by: Vadim Mikhailov

    in LineTracker.cpp about 311 line
    
    change
    // 8<-----------
    // handle cancel messages
    case WM_KEYDOWN:
    if (msg.wParam == VK_ESCAPE)
    {
    bCanceled = TRUE;
    bExit = TRUE;
    };
    break;

    case WM_RBUTTONDOWN:
    bCanceled = TRUE;
    bExit = TRUE;
    break;
    // 8<-----------
    to

    // 8<-----------
    // handle cancel messages
    case WM_KEYDOWN:
    if (msg.wParam == VK_ESCAPE)
    {
    bCanceled = TRUE;
    bExit = TRUE;
    dc.MoveTo(CurPos.Begin );
    dc.LineTo( CurPos.End );
    };
    break;
    // 8<-----------

    case WM_RBUTTONDOWN:
    bCanceled = TRUE;
    bExit = TRUE;
    dc.MoveTo( CurPos.Begin );
    dc.LineTo( CurPos.End );
    break;

    Reply
  • Not release GDI resourses

    Posted by Legacy on 04/03/1999 12:00am

    Originally posted by: Fabian

    Actully if you are using
    pDC->SaveDC
    the correct way should be

    int oldDC = pDC->SaveDC();

    ...

    pDC->RestoreDC(oldDC);

    and also the GDI objects should be delete to avoid resuorces leaking

    LinePen.DeleteObject();
    HandleBrush.DeleteObject();


    Anyway, the KLineTracker is very nice and handy.
    Thank Ivan.


    Fabian

    Reply
  • when line is moved, original line is erased.

    Posted by Legacy on 03/08/1999 12:00am

    Originally posted by: Kang Seung Bum

    When LineTracker is moving, or resizing, original line is erased!!
    Is there solution?

    Reply
  • No viruses reported in Demo project when checked by McAfee NTScan

    Posted by Legacy on 11/14/1998 12:00am

    Originally posted by: Ivan Krivyakov

    When I seen the comment about the virus, 
    
    I re-checked Demo project with McAfee NTScan 3.2.0,
    virus data file V3108. It did not detect any viruses.
    As far as I know, V3108 is the latest data file
    available from McAfee.

    If you are still afraid of virus, you can download
    Demo project without running its EXE file. Because
    Demo project contains all the sources, you can
    re-create EXE file using your compiler.

    Regards.
    Ivan Krivyakov, software engineer

    Reply
  • WebScan alert for a virus on .EXE file

    Posted by Legacy on 11/13/1998 12:00am

    Originally posted by: Davide Zaccanti

    I don't known if this is true, but I've avoided to download demo project.

    Reply
Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • On-demand Event Event Date: September 10, 2014 Modern mobile applications connect systems-of-engagement (mobile apps) with systems-of-record (traditional IT) to deliver new and innovative business value. But the lifecycle for development of mobile apps is also new and different. Emerging trends in mobile development call for faster delivery of incremental features, coupled with feedback from the users of the app "in the wild." This loop of continuous delivery and continuous feedback is how the best mobile …

  • One of the most foolproof ways for an online system to confirm, "Is it really you?" is by adding two-factor authentication. Modern two-factor solutions have evolved to support new, complex technology models that change how we use data, including cloud computing and bring-your-own-device (BYOD). However, not all two-factor authentication solutions are created equal. This guide walks through some of the key area of differentiation between two-factor authentication solutions and provides some concrete criteria …

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds