PDA

View Full Version : حذف موس



www.pc3enter.tk
پنج شنبه 06 خرداد 1389, 19:18 عصر
سلام دوستان
1-من می خواستم وقتی برنامه ی ویژال بیسیک را اجرا می کنم موس پنهان شود و دیده نشود
--------------------------------------------------------------------------------------------------------
سوال دوم
2- می خواهم وقتی برنامه را اجرا ی کنم موس در وسط صفحه قرار بگیرد. و وقتی موس را به حرکت در می آورم دوباره برگردد سر جای خودش .
لطفا اگر می توانید کمک کنید
باتشکر.
:متفکر:

romina2006
جمعه 07 خرداد 1389, 10:46 صبح
جواب سوال اول :


Private Declare Function ShowCursor Lib "user32" (ByVal bShow As Long) As Long
Dim blnShow As Boolean

Private Sub Form_Click()
blnShow = Not blnShow
ShowCursor blnShow
End Sub

Private Sub Form_Load()
blnShow = True
End Sub

Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
If Not blnShow Then
ShowCursor True
End If
End Sub

romina2006
جمعه 07 خرداد 1389, 11:26 صبح
جواب سوال دوم :


Option Explicit

Private Type POINTAPI
X As Long
Y As Long
End Type

Private Declare Function ClientToScreen Lib "user32" (ByVal hwnd As Long, lpPoint As POINTAPI) As Long
Private Declare Function SetCursorPos Lib "user32" (ByVal X As Long, ByVal Y As Long) As Long

Public Function SetCursorPosition(Window As Object, xPos As Long, yPos As Long) As Boolean

On Error GoTo errorhandler

Dim X As Long, Y As Long
Dim lRet As Long
Dim lHandle As Long
Dim typPoint As POINTAPI

lHandle = Window.hwnd
With Screen
X = CLng(xPos / .TwipsPerPixelX)
Y = CLng(yPos / .TwipsPerPixelY)
End With

typPoint.X = X
typPoint.Y = Y

lRet = ClientToScreen(lHandle, typPoint)
lRet = SetCursorPos(typPoint.X, typPoint.Y)


SetCursorPosition = (lRet <> 0)

Exit Function

errorhandler:

SetCursorPosition = False
Exit Function

End Function

Private Sub Form_Load()
SetCursorPosition Me, Screen.Width / 2, Screen.Height / 2
Timer1.Interval = 1000
End Sub

Private Sub Timer1_Timer()
SetCursorPosition Me, Screen.Width / 2, Screen.Height / 2
End Sub