Position the cursor to the ContentAlignment Enum
This subroutine will position the cursor to the ContentAlignment enum.
VB.NET
''' <summary>
''' Sets the cursor's position relative to the screen's width and height.
''' </summary>
''' <param name="pos">The height according to the ContentAlignment enum.</param>
''' <remarks></remarks>
Public Sub cursorRelativeToScreen(ByRef pos As System.Drawing.ContentAlignment)
Select Case pos
Case ContentAlignment.BottomCenter
Windows.Forms.Cursor.Position = New Point( _
Screen.PrimaryScreen.Bounds.Width / 2, Screen.PrimaryScreen.Bounds.Height)
Case ContentAlignment.BottomLeft
Windows.Forms.Cursor.Position = New Point( _
0, Screen.PrimaryScreen.Bounds.Height)
Case ContentAlignment.BottomRight
Windows.Forms.Cursor.Position = New Point( _
Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height)
Case ContentAlignment.MiddleCenter
Windows.Forms.Cursor.Position = New Point( _
Screen.PrimaryScreen.Bounds.Width / 2, Screen.PrimaryScreen.Bounds.Height / 2)
Case ContentAlignment.MiddleLeft
Windows.Forms.Cursor.Position = New Point( _
0, Screen.PrimaryScreen.Bounds.Height / 2)
Case ContentAlignment.MiddleRight
Windows.Forms.Cursor.Position = New Point( _
Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height / 2)
Case ContentAlignment.TopCenter
Windows.Forms.Cursor.Position = New Point( _
Screen.PrimaryScreen.Bounds.Width / 2, 0)
Case ContentAlignment.TopLeft
Windows.Forms.Cursor.Position = New Point(0, 0)
Case ContentAlignment.TopRight
Windows.Forms.Cursor.Position = New Point( _
Screen.PrimaryScreen.Bounds.Width, 0)
End Select
End Sub
' How to call this subroutine:
' In this case you will be setting the mouse to be in the center of the screen.
cursorRelativeToScreen(ContentAlignment.MiddleCenter)
See Also
- </DIC> Submission - http://www.dreamincode.net/code/snippet1509.htm
page_revision: 0, last_edited: 1197782007|%e %b %Y, %H:%M %Z (%O ago)





