Advertisement Jump to content
Sign in to follow this  

vb .net problems

This topic is 4892 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

What I'm trying to do so that my game has a nice look to it but is still very simple to make is to use pictures and then get the coordinates of where the user clicked on the form. I tried using the mousedown event, but that did nothing if I made an If..Then statements or a Select Case statement. When I used the MouseClick event, I couldn't find a way to get the mouse coordinates. If there's a way for me to get the mouse coords in a simple way. And please don't tell me to use c++, because I just like vb better.

Share this post

Link to post
Share on other sites
MouseDown should work fine. Are you sure you didn't do something silly, like writing in the Form's MouseDown while you were clicking in a Panel?

Share this post

Link to post
Share on other sites
Here is my suggestion

Make an event handler for all the objects on your form that might get mousedown fired on them. So instead of just handling mousedown for the form it handles it for all the objects you put on the form that might get in the way (and that you want that behavior for.

you should be able to get the coordinaes from the "e" parameter.

e.X and e.Y should do the job nicely.

They might be relative to the control thats getting clikced...

anyway here is the code I looked at from one of my school projects where I am using mousedown event on a form....

Private Sub Drawform_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseDown
Dim myshape As SigGraphics.shapestorage
Select Case Me.drawmode
Case Is = "Circle"
myshape = New SigGraphics.circlestorage
Case Is = "Square"
myshape = New SigGraphics.squarestorage
Case Is = "Triangle"
myshape = New SigGraphics.trianglestorage
Case Is = "None"
Exit Sub
End Select
myshape.drawmode = Me.fillmode
myshape.x = e.X
myshape.y = e.Y
myshape.startcolor = Me.lblstartcolor.BackColor
myshape.endcolor = Me.lblendcolor.BackColor
End Sub

Share this post

Link to post
Share on other sites
I have nothing displayed on the form at startup, everything is in the form_paint event. I'll try doing some simple programs to check stuff before putting it in the game. I'm not making my transition to .net as easiily as expected.

Edit: I used the Vb6 translator(probably should've mentioned that in the first post but oh well), and it didn't work right. I tried the e.x and the e.y and it works perfectly now. Thanks.

Share this post

Link to post
Share on other sites
Sorry about double posting, but trying to edit gave me problems. At first I used the vb6 translator because I still don't fully understand the power of "e". Using e.x and e.y it works fine. Thansk for the help, although I'll probably be asking another question very soon...

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!