?
Solved

Mouse Control

Posted on 2000-05-03
9
Medium Priority
?
172 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 200 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Expert Comment

by:AshokKumar
ID: 2779495
Thanks Friend. Really nice working for u.
0
 

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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
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…
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…
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…
Suggested Courses

850 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