2

The problem I'm facing is that a control isn't visible when another control is above.

Trying to achieve something similar to: you click the invisible panel, the panel processes the event data into other classes and after it is finished it sends the nested window a similar click event (the nested window needs to be rendered).

Is it even possible?

Edit:

more images..

enter image description here

kw7
  • 63
  • 8
  • Have you looked into the `opacity` property? – JEV Apr 18 '17 at 13:34
  • @Glitch100 My invisible control extends `Panel` and its `BackColor` is set to `Color.FromArgb(0, Color.Black);` The problem is that the Control below the invisible panel wont render – kw7 Apr 18 '17 at 13:40
  • In which case you need filtering events? Just saying.. –  Apr 18 '17 at 13:50
  • https://support.microsoft.com/en-us/help/943454/winforms-how-to-create-a-control-transparent-to-other-controls – Hans Passant Apr 18 '17 at 14:02
  • Nice picture. There is no need for invisible panel (this sounds like XY problem to me), you can simply hook mouse events for a window (in your case main form). See e.g. [here](http://stackoverflow.com/q/4991044/1997232). – Sinatr Apr 18 '17 at 14:04
  • Are you looking for a [Transparent winforms control](http://stackoverflow.com/questions/36710701/make-picture-boxes-transparent-each-overlapping-the-other-with-a-corner)? – Zohar Peled Apr 18 '17 at 14:56
  • @Sinatr thing is that the nested window is one of an external application that i cannot get a `Control` of and communicate with it using `WinApi` – kw7 Apr 18 '17 at 14:56
  • After further testing it appears that when my invisible control tries to do any type of render of a transparent pixel it shows the form background which would be correct if it wouldn't have painted over my nested window – kw7 Apr 18 '17 at 15:07
  • @ZoharPeled your suggestion would have worked if only the nested window had a control, in which i wouldn't have needed an invisible panel in the first place :/ – kw7 Apr 18 '17 at 15:09
  • Then I don't think I understand the question. – Zohar Peled Apr 18 '17 at 15:12
  • ill add another image if it helps – kw7 Apr 18 '17 at 15:15
  • 1
    As an option you can put a transparent overlay over your form using a `TransparentPanel`. I've used such technique in [this example](http://stackoverflow.com/a/40209045/3110834). The user can only have interaction with the transparent panel but not controls. In the example I've decided to draw something on transparent panel based on user click, but controls doesn't receive click. It's a small example, but its the same way which windows forms designer works at design time. The controls which you see at design time, are real controls and are not disabled but they don't receive click. – Reza Aghaei Apr 18 '17 at 16:24
  • that seems like what i've been looking for ill give it a try tomorrow thanks! – kw7 Apr 18 '17 at 18:05
  • couldn't have waited and tried it right now aaaand it works! thanks so much @RezaAghaei and all the others who suggested solutions – kw7 Apr 18 '17 at 18:18

1 Answers1

1

it seems that the solution has to do with to overriding the following methods:

using System.Windows.Forms;
public class TransparentPanel : Panel
{
    const int WS_EX_TRANSPARENT = 0x20;
    protected override CreateParams CreateParams
    {
        get
        {
            CreateParams cp = base.CreateParams;
            cp.ExStyle = cp.ExStyle | WS_EX_TRANSPARENT;
            return cp;
        }
    }
    protected override void OnPaintBackground(PaintEventArgs e)
    {
    }
}

in the invisible panel class I've made as mention by the comments in this example

Community
  • 1
  • 1
kw7
  • 63
  • 8