Link to home
Start Free TrialLog in
Avatar of npaun
npaun

asked on

How to temporary block mouse and keyboard input to my application?

How to temporary prevent users’ mouse and keyboard input to my application window, for instance, when the application is processing some data? I don’t want to use API BlockInput, as it completely blocks input to ALL applications, which is not good. I only need to block input to MY application, for instance in the manner: user hovers mouse over my app window, the cursor changes to Hourglass, and the mouse/keyboard input to my app window is disabled, until the processing is done, and input again explicitly enabled. Ideally, I should be able to specify handle to the window of my app I wish to block, or perhaps event to have option to block input to all windows belonging to my applications.
Avatar of Glen Richmond
Glen Richmond
Flag of United Kingdom of Great Britain and Northern Ireland image

use variations of enabled=true and false to make controls like text boxes and command buttons inaccesible.
i.e.
MyCommandButton.enabled=false
MyTextBox.enabled=false

then for the duration of the processing use screen.mousepoint=11 to show busy..

example of mouse pointer :-
http://support.microsoft.com/kb/71105
Avatar of npaun
npaun

ASKER

well, that was an obvious approach... problem is, I have A LOT of controls on my form, and I would like not to have to disable/enable each and every of them... I'm looking for a more elegant solution, if there is a such...
well i guess im out!
you can use a for each to cycles through the controls and set the enable props without having to implicitly name them all..

for each ctrl in form.controls
     ctrl.enabled=false
next ctrl
Avatar of npaun

ASKER

yes, I'm familiar with that approach too...
guess you dont need me then ... still a thanks wouldnt have hurt!
Avatar of npaun

ASKER

thanks for the post
ASKER CERTIFIED SOLUTION
Avatar of ReneD100
ReneD100
Flag of Netherlands image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of npaun

ASKER

it works, just perfect...
Well, this is a little embarrassing, I've never before had this need, and I simply overlooked the simplest possible approach... I never actually noticed before that the Form too has the Enabled property, nor used it... I simply jumped ahead I assumed there probably must be some convoluted approach... LOL
Thanks. Problem solved.
Haha, sometimes the solutions are very easy! I use it in Access sometimes to make sure users cannot make changes while stuff is being processed behind the scenes. VB6 and VBA aren't that far apart. Glad you got it going though!