Remi_CG
November 12th, 1999, 12:54 PM
Is there anyway you can move the mouse to a certain position on your form?..I just need to now how to put the mouse in different positions on my form
|
Click to See Complete Forum and Search --> : Move Mouse Remi_CG November 12th, 1999, 12:54 PM Is there anyway you can move the mouse to a certain position on your form?..I just need to now how to put the mouse in different positions on my form Sanjeeev November 12th, 1999, 05:43 PM Use mouse_event API call , You will get it Dave Straayer November 12th, 1999, 07:05 PM As noted in other replies, you need to make a WIN API call to move it. But be careful, because you will have to give the location to which to move the mouse cursor in screen, rather than current window, coordinates. If you can assume that your application is maximized on at a known resolution, it simiplifies the problem. 'function that moves the mouse cursor to a X, Y position Declare Function SetCursorPos Lib "user32" (ByVal X As Long, ByVal Y As Long) As Long Here is a not-fully-debugged interface: Sub VBSetCursorPos(X, Y) ' Description: This is a routine to set Mouse Tracking ' Cursor (Arrow, usually) to a position specified ' in the current Visual Basic coordinate system. ' Input: (x,y) - a coordinate pair in the current ' Visual Basis coordinate system ' Output: position of the mouse tracking cursor ' Calls: SetCursorPos - a Win API call to move the ' cursor (in screen pixels) ' Note: Most of what this routine does is to convert a ' pair of coordinates in VB system to screen pixels. ' It also stacks and restores current ' coordinate system. ' ASSUMPTIONS: This routine assumes that the current ' form's left, right, and bottom borders, ' (if any) are of equal width, and any ' extra border is at the top. Dim SaveScaleMode, SaveScaleLeft, SaveScaleTop As Single Dim SaveScaleWidth, SaveScaleHeight As Single Dim LeftBorder, RightBorder, TopBorder, BottomBorder As Single Dim X1, Y1, X2, Y2, X3, Y3 As Single SaveScaleMode = ScaleMode SaveScaleTop = ScaleTop SaveScaleLeft = ScaleLeft SaveScaleHeight = ScaleHeight SaveScaleWidth = ScaleWidth X1 = (X - ScaleLeft) / ScaleWidth Y1 = (Y - ScaleTop) / ScaleHeight ScaleMode = vbPixels X2 = Me.Width / Screen.TwipsPerPixelX Y2 = Me.Height / Screen.TwipsPerPixelY X3 = ScaleWidth Y3 = ScaleHeight LeftBorder = (X2 - X3) / 2 RightBorder = LeftBorder BottomBorder = LeftBorder TopBorder = (Y2 - Y3) - BottomBorder Xpix = X1 * X3 + Left / Screen.TwipsPerPixelX + LeftBorder Ypix = Y1 * Y3 + Top / Screen.TwipsPerPixelY + TopBorder j = SetCursorPos(Xpix, Ypix) ScaleMode = SaveScaleMode ScaleTop = SaveScaleTop ScaleLeft = SaveScaleLeft ScaleHeight = SaveScaleHeight ScaleWidth = SaveScaleWidth End Sub Dave Straayer Varatouch, Inc. codeguru.com
Copyright Internet.com Inc., All Rights Reserved. |