?
Solved

Mouse Control

Posted on 2000-05-03
9
Medium Priority
?
167 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
[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
  • 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

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…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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…
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
Course of the Month7 days, 21 hours left to enroll

765 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