Results 1 to 6 of 6

Thread: draw and select object

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Nov 2004
    Location
    @ My PC
    Posts
    30

    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

  2. #2
    I don't do your homework! opus's Avatar
    Join Date
    Jun 2000
    Location
    Good Old Europe
    Posts
    3,863

    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!

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Nov 2004
    Location
    @ My PC
    Posts
    30

    Re: draw and select object

    specially in VB6 , on picturebox mouse down event how can i realize which polygon is under mouse ?

  4. #4
    I don't do your homework! opus's Avatar
    Join Date
    Jun 2000
    Location
    Good Old Europe
    Posts
    3,863

    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!

  5. #5

    Thread Starter
    Junior Member
    Join Date
    Nov 2004
    Location
    @ My PC
    Posts
    30

    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.

  6. #6
    I don't do your homework! opus's Avatar
    Join Date
    Jun 2000
    Location
    Good Old Europe
    Posts
    3,863

    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
  •  



Click Here to Expand Forum to Full Width