Results 1 to 7 of 7

Thread: [RESOLVED] How to Inhibit Mouse Click Action?

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2006
    Posts
    403

    Resolved [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

  2. #2

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2006
    Posts
    403

    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

  4. #4
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    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
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  5. #5

  6. #6

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2006
    Posts
    403

    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

  7. #7

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2006
    Posts
    403

    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
  •  



Click Here to Expand Forum to Full Width