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
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.
Re: algo for dragging object!!
can u just simply tel that how will u drag a rectangle drawn through
CDC->fillsolidrect .......
Re: algo for dragging object!!
Quote:
Originally Posted by
pinnachio
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.
Re: algo for dragging object!!
thnx u very much ....was doing the same was was having errors....evrything done now .....
thnx ance again