Results 1 to 7 of 7

Thread: Prevent Click Form Below (2 forms)

  1. #1

    Thread Starter
    Fanatic Member mutley's Avatar
    Join Date
    Apr 2000
    Location
    Sao Paulo - Brazil
    Posts
    709

    Prevent Click Form Below (2 forms)

    Hi

    I have 2 forms (A and B), when I am using Forma A I call form B Modal , but when I did a double click in Form B It too click in button in form A . how to prevent click on the form below (A) ?


    Tia
    Last edited by mutley; Jun 30th, 2014 at 11:15 AM.

  2. #2
    Hyperactive Member
    Join Date
    Oct 2013
    Posts
    389

    Re: Prevent Click Form Below (2 forms)

    Should work:

    Clicking a command button on Form1:
    Code:
    Private sub Command1_Click()
        Form1.Enabled = False
        Form2.Show
    End Sub
    Clicking a command button on Form2:
    Code:
    Private sub Command1_Click()    
        Form1.Enabled = True
        Form2.Hide
    End Sub

  3. #3

    Thread Starter
    Fanatic Member mutley's Avatar
    Join Date
    Apr 2000
    Location
    Sao Paulo - Brazil
    Posts
    709

    Re: Prevent Click Form Below (2 forms)

    me again

    work fine when I tried to click in form1 when Form2 is actiive (It did to let), but when I clicked in control in Form2 , It too clicked in control in form1
    Name:  errotela.jpg
Views: 328
Size:  43.5 KB

  4. #4

    Thread Starter
    Fanatic Member mutley's Avatar
    Join Date
    Apr 2000
    Location
    Sao Paulo - Brazil
    Posts
    709

    Re: Prevent Click Form Below (2 forms)

    me again

    work fine when I tried to click in form1 when Form2 is actiive (It did to let), but when I clicked in control in Form2 , It too clicked in control in form1
    Name:  errotela.jpg
Views: 328
Size:  43.5 KB

  5. #5
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    14,206

    Re: Prevent Click Form Below (2 forms)

    I have ran into this issue on handheld devices in the past where the top form unloaded and the click passed through to the bottom form which just happened to have a control at that position.
    I did not go into it very far, my solution was to add a timer control to the form that would enable the form

    So when second form is loaded set the enabled property to false on the first form then when second from is unloaded enabled the timer.
    In the timer tick event enable the first form again. I generally use a timer interval of 100 for something like this which gives you 1/10th second delay between form2 closing and form1 being enabled which is enough time to prevent the click from passing through but not so much that the user notices the form being disabled when they return to it.

  6. #6
    Hyperactive Member
    Join Date
    Oct 2013
    Posts
    389

    Re: Prevent Click Form Below (2 forms)

    Quote Originally Posted by DataMiser View Post
    my solution was to add a timer control to the form that would enable the form
    a bit off-topic here, but i find myself doing the timer thingy as well, but to me its kind of unclean, bulky way, to approach to an issue.
    Anyone got a different idea to efficiently execute a one-time delayed sub, without adding a timer to the form ?
    (excluding the messy unstable Sleep and DoEvents technique).

  7. #7
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    14,206

    Re: Prevent Click Form Below (2 forms)

    I agree it is a bit of a hack in this instance, I was in a rush to solve an issue when i came up with this method.

    I have not however had this issue in any PC based programs, only a handheld app and it only happen in one spot there. The way the app was designed the Exit button was directly behind the button to return to the main menu and when a user touched the screen to return to the menu it would sometimes trigger the exit button and close the app which was a nuisance to say the least.

    This really should not happen with a mouse click unless of course there is some issue with the mouse or you have a user like my wife who will click 3 or 4 times real quick.

    That said using a timer to run a delayed piece of code is perfectly acceptable. Using 5 or 10 of them for this type of thing is not

Tags for this Thread

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