Results 1 to 6 of 6

Thread: [RESOLVED] Cannot MouseClick on Transparent Form Background

  1. #1

    Thread Starter
    Hyperactive Member ...:::ONE:::...'s Avatar
    Join Date
    May 2004
    Location
    Netherlands
    Posts
    282

    Resolved [RESOLVED] Cannot MouseClick on Transparent Form Background

    So, I have a form, and the background color of the form is set to the transparency key, making the background of the form transparent. The problem I'm having, is that the form cannot recognize the MouseClick event (when I click on the transparent background of the form). I figured out that the transparent background is triggering this problem. When I shut off the transparency, everything works fine.

    My question is.. Is there any work around? I still need to use the form to be able to access certain objects that are rendering there, so I don't think I could use something like a "Panel" for example, because the objects will render underneath and possibly make them inaccessible.

    Any Ideas?

    Thanks,
    -Chris
    Last edited by ...:::ONE:::...; Jan 31st, 2012 at 01:13 AM.
    6 Years

  2. #2
    PowerPoster Evil_Giraffe's Avatar
    Join Date
    Aug 2002
    Location
    Suffolk, UK
    Posts
    2,555

    Re: Cannot MouseClick on Transparent Form Background

    You're right, it's exactly the case that the transparency is causing the issue. If you think about it, it kinda makes sense. The user is clicking on what they see on the screen. If something's completely transparent, then the user can't see it and therefore they could never intend to click on the transparent thing.

    The workaround is to make the background almost transparent. Using a very low Alpha component (i.e. 1) will give a colour that is as close to transparent as it can be without actually being transparent. The user can therefore "see" it (as far as the computer is concerned) and therefore can have intended to click on it, so the MouseClick will fire.

  3. #3

    Thread Starter
    Hyperactive Member ...:::ONE:::...'s Avatar
    Join Date
    May 2004
    Location
    Netherlands
    Posts
    282

    Re: Cannot MouseClick on Transparent Form Background

    Yeah I thought about that. But I couldn't make the background semi transparent (that I know of) so in my GUI I have another form in which I made the opacity 70% for a semi transparent look and attached it via coordinates to float behind the "Main" form which the background is fully transparent.

    This is what it looks like if I were to remove the semi-transparent form


    This is what it looks like with the semi-transparent floating form, I cannot make the background of the Main Form (the one with the icons & etc.) semi-transparent, so I was forced to do the following with a floating form behind.


    EDIT:
    I also tried doing the "MouseClick" event one the form floating the main form, I still have the same problem.
    Last edited by ...:::ONE:::...; Jan 30th, 2012 at 07:35 PM.
    6 Years

  4. #4
    PowerPoster boops boops's Avatar
    Join Date
    Nov 2008
    Location
    Holland/France
    Posts
    3,201

    Re: Cannot MouseClick on Transparent Form Background

    Make the floating form the Owner of the main form. You can set the Owner property any of these ways:

    Code:
    Form1.Owner = Form2
    Form2.AddOwnedForm(Form1)
    Form2.Show(Form1)
    BB

  5. #5

    Thread Starter
    Hyperactive Member ...:::ONE:::...'s Avatar
    Join Date
    May 2004
    Location
    Netherlands
    Posts
    282

    Re: Cannot MouseClick on Transparent Form Background

    I tried the ownership code, but it doesn't have any effect. It seems like the mouse isn't clicking through the main form at all.



    -Chris
    6 Years

  6. #6

    Thread Starter
    Hyperactive Member ...:::ONE:::...'s Avatar
    Join Date
    May 2004
    Location
    Netherlands
    Posts
    282

    Re: Cannot MouseClick on Transparent Form Background

    I found out that I had a small line of code I was using for debugging that I never turned off, it had to do with the floating form and it's focus... the problem was that every time I put the floating form in focus (by clicking) it automatically put the main form in focus, which cancelled out any MouseClick events on the floating form.

    Thanks for the help guys, it appeared to be my fault haha... it's sad that 1000 lines of code and 1 line can throw off the whole project.



    Thanks,
    -Chris
    Last edited by ...:::ONE:::...; Jan 31st, 2012 at 01:11 AM. Reason: Solved the problem
    6 Years

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