Solved

Mouse Control

Posted on 2000-05-03
9
161 Views
Last Modified: 2010-05-02
hello Experts,

Is there a way I can disable a mouse  function once i go into the form ?
0
Comment
Question by:dekoay
  • 3
  • 2
  • 2
  • +2
9 Comments
 
LVL 28

Expert Comment

by:AzraSound
ID: 2776358
which function do you want to disable?
0
 

Accepted Solution

by:
AshokKumar earned 50 total points
ID: 2776415
Yes. U can do that. If u want to manipulate cursor alone ie to hide it u can use ShowCursor API call. If u want to disable the right clikc event or something like that use this:

---------Module COde-----

Declare Function CallWindowProc Lib "user32" Alias "CallWindowProcA" (ByVal lpPrevWndFunc As Long, ByVal hWnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Public Const GWL_WNDPROC = -4
Public Const WM_RBUTTONUP = &H205
Public lpPrevWndProc As Long
Private lngHWnd As Long
Public Sub Hook(hWnd As Long)
lngHWnd = hWnd
lpPrevWndProc = SetWindowLong(lngHWnd, GWL_WNDPROC, _
AddressOf WindowProc)
End Sub
Public Sub UnHook()
Dim lngReturnValue As Long
lngReturnValue = SetWindowLong(lngHWnd, GWL_WNDPROC, lpPrevWndProc)
End Sub
Function WindowProc(ByVal hw As Long, _
ByVal uMsg As Long, _
ByVal wParam As Long, _
ByVal lParam As Long) As Long
Select Case uMsg
Case WM_RBUTTONUP
'Do nothing
'Or popup you own menu
Case Else
WindowProc = CallWindowProc(lpPrevWndProc, hw, uMsg, wParam, lParam)
End Select
End Function
---------

Form Code
---------
Private Sub Form_Load()
Call Hook(Text1.hWnd)
End Sub
Private Sub Form_Unload(Cancel As Integer)
Call UnHook
End Sub
-----------


This would give u an idea.
0
 
LVL 6

Expert Comment

by:setiawan
ID: 2776577
Hi dekoay,

What about hide the cursor ?

'put in the module
Declare Function ShowCursor& Lib "user32" _
    (ByVal bShow As Long)
    'Add this code to Command1.


Private Sub Command1_Click()
    ShowCursor (bShow = True)
End Sub

Private Sub Command2_Click()
    ShowCursor (bShow = False)
End Sub

hope this helps

  danny
0
 

Expert Comment

by:AshokKumar
ID: 2779495
Thanks Friend. Really nice working for u.
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Expert Comment

by:wzm
ID: 2791135
Gee ..
Ashok your code was cool .. Never seen
released on Net b4

Yet i wonder to how to disable
all the text boxes, combos, and command buttons which is commonly used on usual form.I try to hook with lengthy parameter (controls'name) and oops ...you know what have i incurred ..

Wzm



0
 
LVL 28

Expert Comment

by:AzraSound
ID: 2791144
you disable those objects by just setting there .enabled property to false
0
 

Expert Comment

by:wzm
ID: 2791200
Dear AzraSound

That's not the idea ...
TQ very much for the prompt respond.

0
 
LVL 28

Expert Comment

by:AzraSound
ID: 2791213
what is the idea?  theres no need to subclass those objects since they have a direct property to prevent the user from editing them.
0
 

Author Comment

by:dekoay
ID: 2791733
Hello wzm,
Perhaps I should u r wrong. The idea for disabling mouse is not allow user to use them.Instead, they use tab key to move from field to field for editing.

Dekoay
:)
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
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 Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…

929 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

11 Experts available now in Live!

Get 1:1 Help Now