shapes on forms

kcwallace

Centurion
Joined
May 27, 2004
Messages
175
Location
Austin, TX
Can anyone direct me to a tutorial on dragging shapes (rectangles, lines, etc.) around a form.

I have figured how to put a shape on a form, but I cannot seem to figure out how to manipulate at runtime by using mouse movements.
 
This is a difficult question to answer without knowing how you have put the shape on the form. As far as I'm aware the shape control that was available in VB wasn't included in the .Net Framework. This leads me to believe you must be drawing them with GDI+ (the Graphics object).

Without making more assumptions (too assume is to make an *** out of u and me) I can't really help much. But assuming everything I've said so far is correct then to move a shape around you would need todo the following.

- Store the shapes region publicly.
- In the mouse down events check if the cursor is in a region (by looping through each region).
- In the mouse move events if the mouse button is down and in a shape, move that shape relative to the cursor position.
- In the mouse up event release control of that shape.

If my assumptions were correct I can provide a more detailed answer, but it seemed pointless here as I'm not entirely convinced I'm thinking along the right lines.
 
Back
Top