Solved

Don't want a mouse pointer over a form!

Posted on 1998-08-31
6
171 Views
Last Modified: 2010-04-30
I am writing a program where I will be creating my own mouse pointer in OpenGL for VB5.  I need to get rid of the standard mouse pointer, whenever the mouse is over the form.

Thanks,

Karsten Wilson
karsten@behsoftware.com
0
Comment
Question by:sungar
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 14

Expert Comment

by:waty
ID: 1432024
Try to set the mousepointer to 4 (Icon) or even to 99 (custom).
and don't forget to set the mouseicon to nothing (I mean, don't set an icon there).
0
 

Author Comment

by:sungar
ID: 1432025
I tried that, but I still get the pointer.  I suppose I could select a blank icon, but that seems like a waste.  Isn't there a more direct way?

Thanks

Karsten
0
 
LVL 2

Expert Comment

by:shchuka
ID: 1432026
I don't remember it exactly, but there's an API function which turns the mouse pointer on and off.  I saw it in the VB API guide about a year ago.
0
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 

Accepted Solution

by:
bad_ima earned 50 total points
ID: 1432027
Use this class to hide/show the cursor!



'cCursor class :
'===============cCursor.cls===============
'Purpose: To provide quick and easy access
'         to cursor functions.
'
'Functions/Subs/Properties:
' -- X (Get/Let): Sets cursor X position
' -- Y (Get/Let): Sets cursor Y position
' -- SnapTo: Puts a cursor in the center
'            of a control.
' -- ClipTo: Restricts the cursor to any
'            square area of movement.
'=========================================

Option Explicit
DefLng A-Z

Private Type POINTAPI
        X As Long
        Y As Long
End Type
Private Type RECT
    Left As Long
    Top As Long
    Right As Long
    Bottom As Long
End Type
Private CurVisible As Boolean
Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Private Declare Function SetCursorPos Lib "user32" (ByVal X As Long, ByVal Y As Long) As Long
Private Declare Function ClientToScreen Lib "user32" (ByVal hWnd As Long, lpPoint As POINTAPI) As Long
Private Declare Function ClipCursor Lib "user32" (lpRect As RECT) As Long
Private Declare Function ShowCursor Lib "user32" (ByVal bShow As Long) As Long

Public Property Get X() As Long

Dim tmpPoint As POINTAPI
Call GetCursorPos(tmpPoint)
X = tmpPoint.X

End Property

Public Property Let X(ByVal vNewValue As Long)

Call SetCursorPos(vNewValue, Y)

End Property

Public Property Get Y() As Long

Dim tmpPoint As POINTAPI
Call GetCursorPos(tmpPoint)
Y = tmpPoint.Y

End Property

Public Property Let Y(ByVal vNewValue As Long)

Call SetCursorPos(X, vNewValue)

End Property

Public Sub SnapTo(ctl As Control)

'Snaps the cursor to the center of
'a given control.

Dim pnt As POINTAPI
Dim xx As Long
Dim yy As Long

pnt.X = pnt.Y = 0
'Get Left-Top corner of control
Call ClientToScreen(ctl.hWnd, pnt)
xx = pnt.X + (ctl.Width \ 2)
yy = pnt.Y + (ctl.Height \ 2)
'xx = pnt.X + ctl.Width / (2 * (Screen.ActiveForm.Left + ctl.Left) / pnt.X)
'yy = pnt.Y + ctl.Height / (2 * (Screen.ActiveForm.Top + ctl.Top) / pnt.Y)
Call SetCursorPos(xx, yy)

End Sub

Public Sub ClipTo(ToCtl As Object)

On Error Resume Next

Dim tmpRect As RECT
Dim pt As POINTAPI

With ToCtl

 If TypeOf ToCtl Is Form Then
  tmpRect.Left = (.Left \ Screen.TwipsPerPixelX)
  tmpRect.Top = (.Top \ Screen.TwipsPerPixelY)
  tmpRect.Right = (.Left + .Width) \ Screen.TwipsPerPixelX
  tmpRect.Bottom = (.Top + .Height) \ Screen.TwipsPerPixelY
 ElseIf TypeOf ToCtl Is Screen Then
  tmpRect.Left = 0
  tmpRect.Top = 0
  tmpRect.Right = (.Width \ Screen.TwipsPerPixelX)
  tmpRect.Bottom = (.Height \ Screen.TwipsPerPixelY)
 Else
  pt.X = 0
  pt.Y = 0
  Call ClientToScreen(.hWnd, pt)
  tmpRect.Left = pt.X
  tmpRect.Top = pt.Y
  pt.X = .Width
  pt.Y = .Height
  Call ClientToScreen(.hWnd, pt)
  tmpRect.Bottom = pt.Y
  tmpRect.Right = pt.X
 End If
 
 Call ClipCursor(tmpRect)

End With

End Sub

Private Sub Class_Initialize()

CurVisible = True

End Sub



Public Property Get Visible() As Boolean

Visible = CurVisible

End Property

Public Property Let Visible(ByVal vNewValue As Boolean)

CurVisible = vNewValue
Call ShowCursor(CurVisible)

End Property

0
 
LVL 2

Expert Comment

by:BergJC
ID: 1432028
This code is much easier, try this:

Declare Function ShowCursor Lib "user32" (ByVal bShow As Long) As Long

Then place this in your code:
ret% = ShowCursor(False)

I'd make sure to set it back after your app is either minimized or closed.
0
 

Author Comment

by:sungar
ID: 1432029
Thanks,

Karsten Wilson
0

Featured Post

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question