Solved

Don't want a mouse pointer over a form!

Posted on 1998-08-31
6
163 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
6 Comments
 
LVL 14

Expert Comment

by:waty
Comment Utility
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
Comment Utility
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
Comment Utility
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
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 

Accepted Solution

by:
bad_ima earned 50 total points
Comment Utility
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
Comment Utility
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
Comment Utility
Thanks,

Karsten Wilson
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

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…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

744 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now