disabling and enabling the mouse in VB

I need to know how to disable then re-enable the  mouse using vb code. I've tried using an API call to disable it but I can't enable it again. Any help would be very much appreciated.
ryan_bullAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

jelliott720Commented:
If you are using a form and you just want to keep the user from clicking on a button or entering data while a procedure is being performed..

Add the following to the procedure..
 '
 Screen.MousePointer = vbHourglass
 Me.Enabled = False
 ' Perform your task here
 '
 Screen.MousePointer = vbDefault
 Me.Enabled = True          
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
rovermCommented:
What API call did you use ?
0
jelliott720Commented:
There is no API call necessary.. The
'Me.Enabled = False' disables the Form, therefore no keystrokes get accepted via the Form.. until your set Me.Enabled = True....
0
The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

jelliott720Commented:
This technique is very effective when the Form is displayed in the Modal mode..The user cannot do anything but Reboot the machine until your ready..
0
caraf_gCommented:
"The user cannot do anything but Reboot the machine until your ready"

In yer dreams. The only thing the user will not be able to do until you're ready is to access anything within the application. Outside the application, you're fine. Thankfully...
0
ryan_bullAuthor Commented:
The api call that I used was:

Shell "rundll32 mouse,disable"
to disable the mouse.

Shell "rundll32 keyboard,disable"
to disable the keyboard.

and

Shell "rundll32 mouse,enable"
to try to enable it again.

but this didn't work.

I'm sorry if I didn't explain it clear enough in my original question, but I need to enable / disable the mouse for the whole computer (not just for a VB form).

The problem is that when I disable the mouse & keyboard using this command I can't re-enable it again.

The reson why I need to do this is for a remote contol application for I.T. demonstrations that moves the mouse on a remote computer, and it would be usefull if the user on the remote computer doesn't use it at the same time as the person using the remote software.

Thanks for any help that you could provide.

Ryan Bull
0
rovermCommented:
This works perfectly:
Place 2 command buttons on a form, named cmdHide and cmdShow then paste this code:

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

Private Sub cmdHide_Click()
Dim i As Integer
   
    Do
        i = ShowCursor(False)
    Loop While i > -1
   
End Sub

Private Sub cmdShow_Click()
Dim i As Integer
   
    Do
        i = ShowCursor(True)
    Loop Until i > 0

End Sub

Good Luck !
RoverM
0
ryan_bullAuthor Commented:
Thanks for that roverm, I tried it out and it worked! there was just one problem - the mouse cursor was still visible and could still be used when it was moved out of the area of the form.
0
caraf_gCommented:
"could still be used when it was moved out of the area of the form"

Absolutely. Windows is (supposed to be) a multi-tasking operating system. It would be horrendous if one application could lock up the whole machine. Those Windows 3.x days are over, and thanks be to Bill. Or whomever.
0
rovermCommented:
Start the sub again within the mouseover event of the form ?

caraf q: who's Bill ;-)) ????

RoverM
0
caraf_gCommented:
Who's Bill... Now there's a Billosophical question with many possiBill answers: Billy The Kid, Bill Clinton, Bill Board, can I have The Bill please, Duck Bill, DeBillitating...

caraf_g
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.