Please help....<br>
<br>
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.<br>
<br>
The code executes without any apparent error but the cursor movement is not restricted to the area of the form being loaded. <br>
<br>
The code itself was unchanged during the conversion. A copy of the code is shown below.<br>
<br>
******************** Start of Code *********************<br>
Private Sub Form_Load()<br>
<br>
Dim CursorClippedArea As CursorArea<br>
Dim bOk As Integer<br>
<br>
' Set form position<br>
' =================<br>
Me.Top = Screen.ActiveForm.Top + (Screen.ActiveForm.Height / 2) - (Me.Height / 2)<br>
Me.Left = Screen.ActiveForm.Left + (Screen.ActiveForm.Width / 2) - (Me.Width / 2)<br>
<br>
Me.Refresh<br>
<br>
' Set cursor area to be the size of this form<br>
' ===========================================<br>
CursorClippedArea.Left = CLng(Me.Left / Screen.TwipsPerPixelX)<br>
CursorClippedArea.Top = CLng(Me.Top / Screen.TwipsPerPixelY)<br>
CursorClippedArea.Right = CLng((Me.Left + Me.Width) / Screen.TwipsPerPixelX)<br>
CursorClippedArea.Bottom = CLng((Me.Top + Me.Height) / Screen.TwipsPerPixelY)<br>
<br>
' Call the API Function<br>
' =====================<br>
bOk = ClipCursor(CursorClippedArea)<br>
<br>
DoEvents<br>
<br>
End Sub<br>
******************** End of Code *********************
<br>
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.<br>
<br>
The code executes without any apparent error but the cursor movement is not restricted to the area of the form being loaded. <br>
<br>
The code itself was unchanged during the conversion. A copy of the code is shown below.<br>
<br>
******************** Start of Code *********************<br>
Private Sub Form_Load()<br>
<br>
Dim CursorClippedArea As CursorArea<br>
Dim bOk As Integer<br>
<br>
' Set form position<br>
' =================<br>
Me.Top = Screen.ActiveForm.Top + (Screen.ActiveForm.Height / 2) - (Me.Height / 2)<br>
Me.Left = Screen.ActiveForm.Left + (Screen.ActiveForm.Width / 2) - (Me.Width / 2)<br>
<br>
Me.Refresh<br>
<br>
' Set cursor area to be the size of this form<br>
' ===========================================<br>
CursorClippedArea.Left = CLng(Me.Left / Screen.TwipsPerPixelX)<br>
CursorClippedArea.Top = CLng(Me.Top / Screen.TwipsPerPixelY)<br>
CursorClippedArea.Right = CLng((Me.Left + Me.Width) / Screen.TwipsPerPixelX)<br>
CursorClippedArea.Bottom = CLng((Me.Top + Me.Height) / Screen.TwipsPerPixelY)<br>
<br>
' Call the API Function<br>
' =====================<br>
bOk = ClipCursor(CursorClippedArea)<br>
<br>
DoEvents<br>
<br>
End Sub<br>
******************** End of Code *********************