Syntax Posted November 6, 2003 Posted November 6, 2003 I need to get the mouse possision into 2 integers is there an easy way to get this code done? i've been searching the net for like 8 hours and only found from VB 6 but that metod is not supported in VB .NET Hope someone can help me with this probobly simple problem. Quote
Administrators PlausiblyDamp Posted November 6, 2003 Administrators Posted November 6, 2003 The mouse_move, mouse_up and mouse_down all contain the x, y co-ordinates as part of the arguments. e.X, e.Y respectively. Or are you looking for the position in some other way? Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Syntax Posted November 6, 2003 Author Posted November 6, 2003 i'm making a drawing program so i need to draw a line with mousedown cordinates to mouseup cordinates. Quote
Administrators PlausiblyDamp Posted November 6, 2003 Administrators Posted November 6, 2003 Do you have any working code so far? Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
pjv Posted November 6, 2003 Posted November 6, 2003 Just handle the mouse move events and store the position from the X and Y properties of MouseEventArgs. Get the stored values in your Paint event and do the drawing there. Simple. Quote
Syntax Posted November 6, 2003 Author Posted November 6, 2003 sorry if i have no clue on what your talking about.. i'm going a visual basic course at school and i'm trying to learn graphics while they others still do if then else the code i got so far is to draw a line. Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs) Dim g As Graphics = e.Graphics Dim pn As New Pen(Color.Black, 3) Dim xval As Integer Dim yval As Integer Dim pt1 As Point = New Point(30, 30) Dim pt2 As Point = New Point(110, 100) g.DrawLine(pn, pt1, pt2) End Sub Quote
Darc Posted November 7, 2003 Posted November 7, 2003 here, I did my own GDI+ Drag-and-drop system for a card game: Dim LastMousePos as New Point(0, 0) Dim CurrMousePos as New Point(0, 0) Private Sub pbx_MouseDown(Byval sender as object, byval e as MouseEventArgs) Handles pbx.MouseDown LastMousePos.X = CurrMousePos.X LastMousePos.Y = CurrMousePos.Y CurrMousePos.X = e.X CurrMousePos.Y = e.Y End Sub Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs) Dim g As Graphics = e.Graphics Dim pn As New Pen(Color.Black, 3) g.DrawLine(pn, LastMousePos, CurrMousePos) End Sub It's late here, I hope this works. Quote
wyrd Posted November 7, 2003 Posted November 7, 2003 You can always use Cursor.Position.X and Cursor.Position.Y if you don't feel like using events. Quote Gamer extraordinaire. Programmer wannabe.
Syntax Posted November 9, 2003 Author Posted November 9, 2003 as usual i don't know how to do it.. i need 1 function to draw the line and i need mousedown to call that function but i have no idea on how to code it.. if anyone can give me the code or would like to help me realtime throu icq or anything please post here. Quote
wyrd Posted November 10, 2003 Posted November 10, 2003 Since you're going to a VB.NET class, why not ask your teacher? It's easier to show someone how to do something than it is to explain it over the internet. Quote Gamer extraordinaire. Programmer wannabe.
Syntax Posted November 10, 2003 Author Posted November 10, 2003 well the teacher won't show me when i'm home.. also i just need the to know how to call the function.. but i just don't know how to it's always something that's not working. Quote
Syntax Posted November 10, 2003 Author Posted November 10, 2003 here, I did my own GDI+ Drag-and-drop system for a card game: Dim LastMousePos as New Point(0, 0) Dim CurrMousePos as New Point(0, 0) Private Sub pbx_MouseDown(Byval sender as object, byval e as MouseEventArgs) Handles pbx.MouseDown LastMousePos.X = CurrMousePos.X LastMousePos.Y = CurrMousePos.Y CurrMousePos.X = e.X CurrMousePos.Y = e.Y End Sub Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs) Dim g As Graphics = e.Graphics Dim pn As New Pen(Color.Black, 3) g.DrawLine(pn, LastMousePos, CurrMousePos) End Sub It's late here, I hope this works. Nope didn't work i must call the draw line function from within the mousedown event. but i wouldn't know hopw to do that. Quote
Syntax Posted November 11, 2003 Author Posted November 11, 2003 Okay i solved it myself. now i'm trying to figure out how to clear the picturebox. any ideas? Quote
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.