kcwallace Posted April 19, 2006 Posted April 19, 2006 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. Quote Go Beavs!!!
Cags Posted April 20, 2006 Posted April 20, 2006 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. Quote Anybody looking for a graduate programmer (Midlands, England)?
kcwallace Posted April 20, 2006 Author Posted April 20, 2006 Your asumption was correct Quote Go Beavs!!!
Cags Posted April 20, 2006 Posted April 20, 2006 Depending on why you are doing this it may be worth making a shape class and then inheriting it to make Square, Circle, or whatever classes. Quote Anybody looking for a graduate programmer (Midlands, England)?
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.