ClipCursor in VB5 and NT4
ClipCursor in VB5 and NT4
(OP)
Please help....
While converting an application from VB3 (16bit API) to VB5 (32bit API) code used to restrict movement of the cursor using ClipCursor API call no longer works.
The code executes without any apparent error but the cursor movement is not restricted to the area of the form being loaded.
The code itself was unchanged during the conversion. A copy of the code is shown below.
******************** Start of Code *********************
Private Sub Form_Load()
Dim CursorClippedArea As CursorArea
Dim bOk As Integer
' Set form position
' =================
Me.Top = Screen.ActiveForm.Top + (Screen.ActiveForm.Height / 2) - (Me.Height / 2)
Me.Left = Screen.ActiveForm.Left + (Screen.ActiveForm.Width / 2) - (Me.Width / 2)
Me.Refresh
' Set cursor area to be the size of this form
' ===========================================
CursorClippedArea.Left = CLng(Me.Left / Screen.TwipsPerPixelX)
CursorClippedArea.Top = CLng(Me.Top / Screen.TwipsPerPixelY)
CursorClippedArea.Right = CLng((Me.Left + Me.Width) / Screen.TwipsPerPixelX)
CursorClippedArea.Bottom = CLng((Me.Top + Me.Height) / Screen.TwipsPerPixelY)
' Call the API Function
' =====================
bOk = ClipCursor(CursorClippedArea)
DoEvents
End Sub
******************** End of Code *********************
While converting an application from VB3 (16bit API) to VB5 (32bit API) code used to restrict movement of the cursor using ClipCursor API call no longer works.
The code executes without any apparent error but the cursor movement is not restricted to the area of the form being loaded.
The code itself was unchanged during the conversion. A copy of the code is shown below.
******************** Start of Code *********************
Private Sub Form_Load()
Dim CursorClippedArea As CursorArea
Dim bOk As Integer
' Set form position
' =================
Me.Top = Screen.ActiveForm.Top + (Screen.ActiveForm.Height / 2) - (Me.Height / 2)
Me.Left = Screen.ActiveForm.Left + (Screen.ActiveForm.Width / 2) - (Me.Width / 2)
Me.Refresh
' Set cursor area to be the size of this form
' ===========================================
CursorClippedArea.Left = CLng(Me.Left / Screen.TwipsPerPixelX)
CursorClippedArea.Top = CLng(Me.Top / Screen.TwipsPerPixelY)
CursorClippedArea.Right = CLng((Me.Left + Me.Width) / Screen.TwipsPerPixelX)
CursorClippedArea.Bottom = CLng((Me.Top + Me.Height) / Screen.TwipsPerPixelY)
' Call the API Function
' =====================
bOk = ClipCursor(CursorClippedArea)
DoEvents
End Sub
******************** End of Code *********************
RE: ClipCursor in VB5 and NT4
-ml
Mike Lacey
Mike_Lacey@Cargill.Com
Cargill's Corporate Web Site