CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    May 2009
    Posts
    88

    Post algo for dragging object!!

    am designing a project in which i have to allow users to allow drag various shapes that are made according to the request of user on layout can ne1 plz suggest me some algo for this......
    this is what I thought

    1.compare the pixel of point where left click occurs with d colour of any valid shape colour that is previously defined.
    2.if found to any object go through all index of all shapes of that type
    3.Now i have to compare this point with all boundries of all objects of this shape


    PLZZ SUGGEST ANY THING FOR STEP-3

  2. #2
    Join Date
    Jul 2002
    Posts
    2,543

    Re: algo for dragging object!!

    Your algorithm doesn't contain Z-order handling, which is important in such situations. I don't think that color is reliable criterion for hit test - usually objects are checked by Z-order, from highest to lowest, and first object which contains the point, is selected.
    Check out MFC sample DRAWCLI, it contains all required algorithms.

  3. #3
    Join Date
    May 2009
    Posts
    88

    Re: algo for dragging object!!

    can u just simply tel that how will u drag a rectangle drawn through
    CDC->fillsolidrect .......

  4. #4
    Join Date
    Sep 2004
    Location
    Holland (land of the dope)
    Posts
    4,123

    Re: algo for dragging object!!

    Quote Originally Posted by pinnachio View Post
    can u just simply tel that how will u drag a rectangle drawn through
    CDC->fillsolidrect .......
    Create a separate image that contains the image/rect you want to drag. In the OnPaint you draw the separate image on the mainscreen. In the OnMouseDownClick you detect if the mouse coordinate is over your separate image, if so set some boolean to true. In the OnMouseMove you check if that boolean is true and move the separate image according to the current mouse coordinates and update the mainscreen to it redraws. In the OnMouseUpClick set the boolean to false, so that the dragging stops.

  5. #5
    Join Date
    May 2009
    Posts
    88

    Re: algo for dragging object!!

    thnx u very much ....was doing the same was was having errors....evrything done now .....
    thnx ance again

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured