Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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.

Posted

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.

Posted

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

Posted

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.

Posted
You can always use Cursor.Position.X and Cursor.Position.Y if you don't feel like using events.
Gamer extraordinaire. Programmer wannabe.
Posted

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.

Posted
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.
Gamer extraordinaire. Programmer wannabe.
Posted

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.

Posted
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.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...