|
-
Sep 26th, 2011, 08:41 PM
#1
Thread Starter
Hyperactive Member
[RESOLVED] How to Inhibit Mouse Click Action?
I fear that there will be a VERY simple answer to this question, but have not managed to find it on this or many other sites.
My program calls up some quite lenghy sub routines, which take several minutes to complete. In the meantime an impatient user could be clicking on things in the form and cause the program subsequently to malfunction.
The need is for a statement which, at the start of a routine, inhibits any effect of the mouse and a corresponding statement at the end of the routine which re-enables the mouse. It would not matter if mouse movement were still possible, so long as mouse clicks are ignored.
Bet the answer to this is absolutely fundamental, but I have failed to find it, and so request your patient assistance.
camoore
Wales, UK
Last edited by camoore; Sep 26th, 2011 at 08:44 PM.
Reason: Typo
-
Sep 26th, 2011, 08:43 PM
#2
Re: How to Inhibit Mouse Click Action?
Me.enabled = False
That's pretty crude so you could disable individual controls.
-
Sep 26th, 2011, 09:30 PM
#3
Thread Starter
Hyperactive Member
Re: How to Inhibit Mouse Click Action?
Thank you Martin.
I tried this code, but it did not work. Having written a code line Me.Enabled = False before my program entered its quite long subroutine/loops, and a Me.Enabled = True again at the end of the loops, it nonetheless then tried to act upon things clicked upon between those two statements.
The need is to make the program ignore anything to do with the mouse between an "ignore mouse" statement and a "re-recognise mouse" statement.
camoore
Wales, UK
-
Sep 26th, 2011, 09:36 PM
#4
Re: How to Inhibit Mouse Click Action?
Right... we get that... the Me.Enabled = False should have disabled the form, there by ignoring any clicks... the assumption was that you put the Me.Enabled = False inside the form itself, as the first line of the click event of the button.
-tg
-
Sep 26th, 2011, 10:22 PM
#5
Re: How to Inhibit Mouse Click Action?
See if this works for you.
Declare Function BlockInput Lib "user32" (ByVal fBlock As Long) As Long
' Block all input
BlockInput True
' Unblock
BlockInput False
-
Sep 26th, 2011, 11:17 PM
#6
Thread Starter
Hyperactive Member
Re: How to Inhibit Mouse Click Action?
Techgnome : Yes, I tried Martin's code at the first stage of the command button which instigated the extended code loop my program was entering (takes some minutes). This command button was within the form in question.
Martin : That suggestion looks interesting. It is now 0515 with me, and my sack calls. Will try it later today.
Thank you both for your helpful replies.
camoore
Wales, UK
-
Sep 27th, 2011, 06:34 AM
#7
Thread Starter
Hyperactive Member
Re: How to Inhibit Mouse Click Action?
Martin,
I tested your suggestion and, with a slight mod., it seems to work perfectly.
At option explicit I wrote :
Private Declare Sub BlockInput Lib "user32" (ByVal fBlock As Long)
'used to inhibit mouse during subroutines etc.
Then in the program code BlockInput True at the start of a routine and BlockInput False at the end.
This freezes the mouse for the duration (of whatever is going on between True and False) and re-enables the mouse on its completion. That prevents a user from clicking on anything while the routine is running which might otherwise crash the program or cause complications when the routine finishes.
Exactly what I was seeking. Many thanks Martin.
camoore
Wales, UK
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|