VB.NET School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!

 

Code Snippets

  

VB.NET Source Code


Welcome to Dream.In.Code
Become a VB.NET Expert!

Join 340,144 VB.NET Programmers for FREE! Get instant access to thousands of VB.NET experts, tutorials, code snippets, and more! There are 3,812 people online right now. Registration is fast and FREE... Join Now!




Position the cursor to the ContentAlignment Enum

Position's the cursor on the screen with the System.Drawing.ContentAlignment enumeration.

Submitted By: RodgerB
Actions:
Rating:
Views: 2,572

Language: VB.NET

Last Modified: December 6, 2007
Instructions:
1) Copy and paste the snippet below into a class.
2) Read how to call the snippet.

Snippet


  1. ''' <summary>
  2. ''' Sets the cursor's position relative to the screen's width and height.
  3. ''' </summary>
  4. ''' <param name="pos">The height according to the ContentAlignment enum.</param>
  5. ''' <remarks></remarks>
  6.  
  7. Public Sub cursorRelativeToScreen(ByRef pos As System.Drawing.ContentAlignment)
  8.  
  9.     Select Case pos
  10.         Case ContentAlignment.BottomCenter
  11.             Windows.Forms.Cursor.Position = New Point( _
  12.             Screen.PrimaryScreen.Bounds.Width / 2, Screen.PrimaryScreen.Bounds.Height)
  13.         Case ContentAlignment.BottomLeft
  14.             Windows.Forms.Cursor.Position = New Point( _
  15.             0, Screen.PrimaryScreen.Bounds.Height)
  16.         Case ContentAlignment.BottomRight
  17.             Windows.Forms.Cursor.Position = New Point( _
  18.             Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height)
  19.         Case ContentAlignment.MiddleCenter
  20.             Windows.Forms.Cursor.Position = New Point( _
  21.             Screen.PrimaryScreen.Bounds.Width / 2, Screen.PrimaryScreen.Bounds.Height / 2)
  22.         Case ContentAlignment.MiddleLeft
  23.             Windows.Forms.Cursor.Position = New Point( _
  24.             0, Screen.PrimaryScreen.Bounds.Height / 2)
  25.         Case ContentAlignment.MiddleRight
  26.             Windows.Forms.Cursor.Position = New Point( _
  27.             Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height / 2)
  28.         Case ContentAlignment.TopCenter
  29.             Windows.Forms.Cursor.Position = New Point( _
  30.             Screen.PrimaryScreen.Bounds.Width / 2, 0)
  31.         Case ContentAlignment.TopLeft
  32.             Windows.Forms.Cursor.Position = New Point(0, 0)
  33.         Case ContentAlignment.TopRight
  34.             Windows.Forms.Cursor.Position = New Point( _
  35.             Screen.PrimaryScreen.Bounds.Width, 0)
  36.     End Select
  37.  
  38. End Sub
  39.  
  40. ' How to call this subroutine:
  41. ' In this case you will be setting the mouse to be in the center of the screen.
  42. cursorRelativeToScreen(ContentAlignment.MiddleCenter)

Copy & Paste


Comments

There are currently no comments for this snippet. Be the first to comment!

Add comment


You must be registered and logged on to </dream.in.code> to leave comments.





Live VB.NET Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

VB.NET Tutorials

Reference Sheets

VB.NET Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month