WS_EX_LAYERED window appearing invisible over RDP - c++

I have developed a screen capture application for Windows using pure Win32 - no MFC or ATL.
To do this, I am using two top-level layered windows - one (entirely transparent) to capture mouse events like dragging, and another (semi-transparent) to act as a highlight rectangle. When a user is selecting the area of their screen to grab, I used SetWindowPos() to change the size and position of the semi-transparent highlight window.
This works fine on a physical device, but I have discovered that on a virtual machine (Windows 7) over RDP, my semi-transparent window doesn't show at all. I can still capture the screen, but not provide visual feedback to the user mid-capture.
I have tried altering my RDP settings to use 32bpp, but that doesn't help.
I am using:
COLORRED highlightColor = RGB(0, 0, 255);
SetLayeredWindowAttributes(hWnd, highlightColor, 255*0.6, LWA_ALPHA);
in the WM_CREATE event for my highlight window.
Does anybody know how to display a semi-transparent layered window over RDP on a VM?

Related

windows API : Pass mouse click through windows

I'm working on an on-screen Annotation flutter desktop app where I want to let the mouse click pass through to the window beneath my window. Now Basically I know that there is a win32api window that hosting the flutter content.
Also, I was able to find a way by using SetWindowLong and applying GWL_EXSTYLE to my window.
int extendedStyleSettings = GetWindowLong(window,GWL_EXSTYLE);
SetWindowLong(window,GWL_EXSTYLE, extendedStyleSettings | WS_EX_LAYERED | WS_EX_TRANSPARENT);
SetLayeredWindowAttributes(window, 0, 255, LWA_ALPHA);
The problem with this solution is I don't know how to restore mouse event on windows or keep it active on my window because I can't do anything I can't click on the border, caption bar, system menu, or minimize/maximize/close buttons.
It just completely disables my window

Transparent hwnd window

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);

OpenGL Non-exclusive Fullscreen Mode (A.K.A. Fullscreen Borderless Window)

I'm trying to get support for a fullscreen borderless window working but none of the information I've found helps.
Regardless of whether or not the window is set as WS_EX_TOPMOST, the window will always be in exclusive fullscreen mode. I've checked the window styles in games using fullscreen borderless window mode with WinSpy++ and the styles I'm using are identical.
I know it's in exclusive fullscreen mode because WDM stops rendering the little aero preview thing for my window. I also get that desktop flicker from focusing and unfocusing the window.
The only way I've been able to get a behaviour similar to what I want is by tricking windows into thinking I don't want fullscreen mode. The way I do that is by adjusting the window position by 1px so that it doesn't match the position and size of the screen. This stops Windows from automatically turning on exclusive fullscreen mode.
I know in DirectX the solution to this is simply to create the device with the windowed flag set to true. However, I have never seen anything like that in OpenGL.
Edit as per first comment:
I'm not using any third party library for my windowing, just Win32 and OpenGL.
Edit:
I am using WS_POPUP as the window style. With this same window style in some DirectX tests I did, I can properly create a fullscreen borderless window or a fullscreen exclusive window by changing the 'windowed' property.
For hardware I'm using a GTX690 with the latest drivers on Win7 x64.
Use PFD_SUPPORT_COMPOSITION in the PIXELFORMATDESCRIPTOR of ChoosePixelFormat/SetPixelFormat.
See The OpenGL Pipeline Newsletter - Volume 003

windows beneath not being painted when using a layered window

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.

How to draw something to the screen and have the underlying ui interactive

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.