Can i make a non popup window transparent and also ensure the child windows are not transparent?
Also i have to block click through by transparent window?
Hi if you mean transparent and not invisible, have a look at Alpha Blending.
Related
Can I remove or decorate the white border of the window top border
i use qt::customizewindowhint
It looks like you need a borderless window, reading the doc can help:
Produces a borderless window. The user cannot move or resize a borderless window via the window system. On X11, the result of the flag is dependent on the window manager and its ability to understand Motif and/or NETWM hints. Most existing modern window managers can handle this.
https://doc.qt.io/qt-5/qt.html#WindowType-enum
setWindowFlags(Qt::Window | Qt::FramelessWindowHint)
Is it possible to create a "transparent" hwnd window ? What I mean by that is that there is no background or borders of that window but that only text is visible...like if I have a main window background and I have something written on the background ( or if I just want to add text on some area via window ) and I want to make it a clickable option, to create that kind of window that will be invisible but still clickable.
On Windows 2000 and later, you can create a top-level window with the WS_EX_LAYERED style (on Windows 8 and later, child windows can now use the WS_EX_LAYERED style as well), and then use SetLayeredWindowAttributes() or UpdateLayeredWindow() to make the window transparent.
Create a solid background color, and then set that color as the window's transparent color. Anything on the window that is not using that color will not be transparent. The OS will handle the rest for you.
Refer to MSDN for more details:
Layered Windows
Using Layered Windows
SetLayeredWindowAttributes()
UpdateLayeredWindow()
From your tag of hwnd, I'm assuming that you are working with C++ or at least have access to the Win32 API, there are plenty of resources to help you get started. The concept is called Window Compositing.
Transparent win32 window and text
Quick and Dirty Window Transparency
If you use WPF instead of C++, here's a link:
Transparent Windows in WPF
First set the styles to enable the layers:
SetWindowLong(itsec->first, GWL_EXSTYLE, GetWindowLong(itsec->first, GWL_EXSTYLE) & WS_EX_LAYERED);
Then indicate if you want the transparency to be alpha or not:
SetLayeredWindowAttributes(itsec->first, RGB(154,255,214), 200, LWA_ALPHA);
I will try to explain my problem the best i can,
I'm creating a layered window in c++ (using windowsXP), all works fine until i drag my created window near the windows start button, and then when i press the star button of windows taskbar and close it again all the windows beneath of my layered window aren't being painted (only in the area of the start window that pops over my window).
My create window is like this:
CWnd::CreateEx( WS_EX_TOOLWINDOW |
WS_EX_LAYERED,
AfxRegisterWndClass(0),
lpstr_name, WS_POPUP, 0,0,0,0,
pc_parent->GetSafeHwnd(), 0);
...
When i create the window with this styles the problem ocurrs, but if i create with the extended style WS_EX_TRANSPARENT and all the others the problem does not occur any more. And if instead of a WS_POPUP window is a WS_CHILD or WS_OVERLAPPED then this also doesn't occur...
Can anyone please explain why when i create a WS_POPUP window with the WS_EX_LAYERED style all the beneath windows aren't updated, and if i add the style WS_EX_TRANSPARENT this works fine.
Note: why i do not use the WS_EX_TRANSPARENT style if it works right? if i use it then my window can not be dragged and i need it to do it :)
Updated:
alt text http://img17.imageshack.us/img17/586/clipboard01il.jpg
The image above is to describe better what is happening:
The first part of the image you can see my leyered window and beneath is the vs, in the second img i press the start button and then in the last image i already drag my layered window to the right and you can see that the vs window does not updates the affected area.
Note that this situation until now only occurs with the start window?! with other windows it does not happen!?...
Thanks
only in the area of the start window that pops over my window
That's expected. Only that clipping rectangle is obscured by the start menu so only that region will be repainted. What behavior are you expecting? If there are windows covered by more upper level windows, then they won't be repainted either -- why repaint something just to paint over it?
All underneath windows need to get repainted though if you use transparent because GDI can't calculate the final color of the pixel without knowing the area below the window's color.
I seeking solution for Windows first.
I need to add visual effects to screen image without breaking the interactivity of all and every controls, that are on this screen.
The solution can be straightforward:
1. take a screenshot
2. show this screenshot in a separate window, above other windows
3. apply the effect to image, being shown on this window
But, this window (containing screenshot) makes any buttons and other controls below, unreachable for mouse interaction (clicking, hovering)
Is there any way to do this ?
From MSDN's documentation on layered windows...
"Hit testing of a layered window is based on the shape and transparency of the window. This means that the areas of the window that are color-keyed or whose alpha value is zero will let the mouse messages through. However, if the layered window has the WS_EX_TRANSPARENT extended window style, the shape of the layered window will be ignored and the mouse events will be passed to other windows underneath the layered window."
Here's an article about it. Notice this additional warning:
"setting the WS_EX_TRANSPARENT attribute affects the entire window: the user can't close the window using the 'x' button, select it with the mouse, or select any controls on the window. The application can still close the window programmatically."
Depending on what you're actually drawing and where, it might be more appropriate to use Owner-Drawn Controls rather than hover an "onion skin" over your whole window.
How can I make for example only a rectangle inside the window have opacity like 50% or something like that and for that part to have the effect of WS_EX_TRANSPARENT so that mouse clicks will go through it?
I do not think it is possible simply by setting WS_EX_TRANSPARENT, but it can be accomplished using two windows, create a window with a hole, using SetWindowRgn, and inside that hole put another transparent window using WS_EX_LAYERED and WS_EX_TRANSPARENT styles.
Take a look at the SetLayeredWindowAttributes Win32 function.
It can be used to set the opacity and transparency of a window.
Take a look at this CodeProject article: Cool, Semi-transparent and Shaped Dialogs with Standard Controls for Windows 2000 and Above.