|
-
Apr 25th, 2007, 03:39 AM
#1
Thread Starter
Junior Member
draw and select object
hi
i need help about a drawing project...
i want draw polygons and text in a picture box and after drawing select them and move or change their properties . ??
thanx
-
Apr 25th, 2007, 06:39 AM
#2
Re: draw and select object
VB6 or vb.net?
in Vb6:
use PolylineApi to draw a Polygone
Declaration:
Code:
Declare Function PolyPolygon Lib "gdi32" Alias "PolyPolygon" (ByVal hdc As Long, lpPoint As POINTAPI, lpPolyCounts As Long, ByVal nCount As Long) As Long
To determine the selection of that polygone you have to do some coding like, determine the click-positionand check if the click is on the polygone (maybe you only use the corner-points).For a movement you would need to redraw everxthing on the picturebox (including the changed polygone).
To draw text onto a picturebox use a label-control, that one will detect a click on it by itself.
You're welcome to rate this post!
If your problem is solved, please use the Mark thread as resolved button
Wait, I'm too old to hurry!
-
Apr 25th, 2007, 05:53 PM
#3
Thread Starter
Junior Member
Re: draw and select object
specially in VB6 , on picturebox mouse down event how can i realize which polygon is under mouse ?
-
Apr 26th, 2007, 12:26 AM
#4
Re: draw and select object
In the Mousedown event, you get the x and y of the mouse, check this position against the positional data of all polygons you have (in my case, I check only the cornerpoints, since these discribe the polygon). If the click is close enough to one point of the polygon, you have detected the polygon. Now you can mark it as selected (either in code or on the screen).
You're welcome to rate this post!
If your problem is solved, please use the Mark thread as resolved button
Wait, I'm too old to hurry!
-
Apr 26th, 2007, 04:50 AM
#5
Thread Starter
Junior Member
Re: draw and select object
thanx , i understand the algorithm but i need sample code...
i have X and Y of mouse but in a picture box the polygon doesn't have handle to select them. so what can i do ?
Last edited by mehdi0016; Apr 26th, 2007 at 05:07 AM.
-
Apr 26th, 2007, 05:06 AM
#6
Re: draw and select object
OK,
If you "detect" a ploygon just save it's ID (Name of polygon, number of index or whatever). Having saved the ID you can do whatever you need to that polygon (like draw a selected box around a cornerpoint, draw it in a different color, move every point etc.). But you need to declare a variable to save this info.
If all your polygons are in an array just save its index in a "PolygonSelected" variable (that it's easy to do any changes to the ploygon).
You're welcome to rate this post!
If your problem is solved, please use the Mark thread as resolved button
Wait, I'm too old to hurry!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|