9 Replies - 463 Views - Last Post: 15 March 2012 - 06:04 AM Rate Topic: -----

#1 Twistedwheelbarrow  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 15-March 12

How do you position the mouse on form load

Posted 15 March 2012 - 05:25 AM

I'm making a maze game for part of my college course and I need to have the mouse spawn in a specific location when the form loads. How would I do this?

Thanks in advance.
Is This A Good Question/Topic? 0
  • +

Replies To: How do you position the mouse on form load

#2 rusoaica  Icon User is offline

  • D.I.C Head

Reputation: 23
  • View blog
  • Posts: 178
  • Joined: 10-March 12

Re: How do you position the mouse on form load

Posted 15 March 2012 - 05:31 AM

hello
u can use this:
Declare the function
Declare Function SetCursorPos& Lib "user32" (ByVal p As Point)

dim p as point
p.x = 100
p.y = 200
SetCursorPos p



or, this:
Windows.Forms.Cursor.Current.Position = New System.Drawing.Point(225, 105)

hope this helps! :)
Was This Post Helpful? 0
  • +
  • -

#3 Twistedwheelbarrow  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 15-March 12

Re: How do you position the mouse on form load

Posted 15 March 2012 - 05:36 AM

Neither seem to work correctly for me
Was This Post Helpful? 0
  • +
  • -

#4 rusoaica  Icon User is offline

  • D.I.C Head

Reputation: 23
  • View blog
  • Posts: 178
  • Joined: 10-March 12

Re: How do you position the mouse on form load

Posted 15 March 2012 - 05:40 AM

did you put the Windows.Forms.Cursor.Current.Position = New System.Drawing.Point(225, 105) inside your form load sub or outside it?
Was This Post Helpful? 0
  • +
  • -

#5 Twistedwheelbarrow  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 15-March 12

Re: How do you position the mouse on form load

Posted 15 March 2012 - 05:42 AM

Inside the load form but it loads at a completely different point to where I need it, even when I enter the correct coordinates
Was This Post Helpful? 0
  • +
  • -

#6 rusoaica  Icon User is offline

  • D.I.C Head

Reputation: 23
  • View blog
  • Posts: 178
  • Joined: 10-March 12

Re: How do you position the mouse on form load

Posted 15 March 2012 - 05:44 AM

well, when you enter different coordinates, does the mouse position change or it is the same regardless of what coordinates you set?
Was This Post Helpful? 0
  • +
  • -

#7 Twistedwheelbarrow  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 15-March 12

Re: How do you position the mouse on form load

Posted 15 March 2012 - 05:47 AM

It changes but when it does the form position changes when it loads :|
Was This Post Helpful? 0
  • +
  • -

#8 rusoaica  Icon User is offline

  • D.I.C Head

Reputation: 23
  • View blog
  • Posts: 178
  • Joined: 10-March 12

Re: How do you position the mouse on form load

Posted 15 March 2012 - 05:58 AM

try to set the Start Position property of the form to CenterScreen. Is that working?

i dont know why..this should work... try it this way. type this in the form load sub:
Dim PositionX As Integer
Dim PositionY As Integer

PositionX = 100
PositionY = 300

Cursor.Position = New Point(PositionX, PositionY)



Was This Post Helpful? 1
  • +
  • -

#9 Twistedwheelbarrow  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 15-March 12

Re: How do you position the mouse on form load

Posted 15 March 2012 - 06:01 AM

View Postrusoaica, on 15 March 2012 - 05:58 AM, said:

try to set the Start Position property of the form to CenterScreen. Is that working?

i dont know why..this should work... try it this way. type this in the form load sub:
Dim PositionX As Integer
Dim PositionY As Integer

PositionX = 100
PositionY = 300

Cursor.Position = New Point(PositionX, PositionY)




This worked, thanks! :D
Was This Post Helpful? 0
  • +
  • -

#10 rusoaica  Icon User is offline

  • D.I.C Head

Reputation: 23
  • View blog
  • Posts: 178
  • Joined: 10-March 12

Re: How do you position the mouse on form load

Posted 15 March 2012 - 06:04 AM

glad i could help you! :)
Live long and prosper! \\//_
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1