Problem with transparent window and WS_CHILD window


#1

I am creating an application that has a non-rectangular shape. So my application parent windows is just derived from Component, not from TopLevelWindow.

I am trying to add a Windows child window to it by using CreateWindow() with the WS_CHILD bit set. For the parent HWND is just use myMainJuceComponent->getWindowHandle().

When the child window has been added, it will not appear, unless I derive my juce parent window from TopLevelWindow, but then my app is not transparent anymore.

What’s the reason for this and what’s the cure?


#2

Ah, good old microsoft! The reason is that the way winXP does transparent windows is such a total bodge that they can’t actually contain child windows. The cure is to rewrite the operating system…


#3

I’m confused - why are you using windows to add a child window to it? why not just use juce components?


#4

Well the thing is that I have to use some external window for some player component, which basically is a child window.

Jules, are you sure that child windows are not visible on a WS_EX_LAYERED window? Here’s a source code I found which seems to use child components on some transparent window: http://damb.dk/transparent.php

I also wrote a fast test application using Borland C++ Builder, where the main window is transparent (WS_EX_LAYERED, transparent and background color set to black, so i only see the frame of the window) and therein i put a child window and it works. the only problem is that the text on the child window is black and therefore now also transparent… perhaps there is some workaround for that though…

So… is there are workaround? Or how can I make a non-rectangular JUCE application while still putting some child window on it?


#5

Maybe I’m getting confused, but I’m sure I remember there being some kind of problem with child windows…


#6

Well, there seems to be one, in Juce. But not in regular windows apps. I will send you a screenshot of my windows app having a child window to prove that there is absolutely no problem to use Child Windows on a layered parent window.

I noticed that JUCE components don’t have HWND’s when I go over the Juce Window with SPY++. How do you manage to create semi-transparency (like the shadows of Juce applications) ? I have the feeling that JUCE always paints over my child window and therefore it is not visible, could this be the case?


#7

Juce comps are all lightweight, it’s all rendered internally. If you’re having difficulty with it painting over child windows, see the ComponentPeer’s masked region methods.


#8