Mouse input transparency in Qt without visual transparency - c++

I know of Qt::WindowTransparentForInput which makes a window and all of its chilren transparent, and QWidget::mask which also visually clips the region outside. I want to draw a window with client side shadows, so I need mouse input- but not visual transparency. How is this possible?

Related

Draw moving icon that is top most all the time like mouse cursor and work for full screen apps

I need to draw an icon that moves approximately in sync with mouse cursor and is always on top of all windows.
OS: Windows 7
I have a solutions that work to some extend by drawing my icon in a top most transparent window. There are some major drawbacks in this solution since that top most window interferes with other top most windows and some full screen apps do not work correctly. Examples are start menu and task bar that will overlay my window if I do not regulary set it to be top most. For some full screen applications performance of updating position of window with icon hugely drops and it does not follow mouse smoothly.
There is another method that I came across where an icon is drawn directly to the device context of desktop Draw mouse pointer icon?. This solution has a drawback that there seems to be no good way of how to remove "trail", especially if desktop content changes quickly.
So my question: is there an ultimate solution that does not have the above mentioned problems?
Is it possible to draw above all windows in the "layer" of mouse cursor? Or make a second mouse cursor with my custom icon that I will control (I know that widows can display two independently controlled mouse cursors like CPNMouse)?
Can someone point me to the right direction?
Thanks!
Use a top-most window with transparency set via WS_EX_LAYERED / UpdateLayeredWindow.
If you set the WS_EX_TRANSPARENT style as well then the window won't intercept mouse input.

Black highlight bar with GDI

I got some nice splitter code for my GUI but I can't get the pen/brush/whatever it is I need to do proper highlighting. You know how in visual studio 10, the splitter bars can be dragged and there's a beautiful black transparent bar letting you know where the split will happen when you lift up your mouse button. Here's a picture: http://www.freeimgshost.com/fullsize/efmcxyyu1wbyb1r7mz0.png
How can I achieve that black highlight bar using solely GDI and c++?
The Visual Studio UI is implemented in WPF, so I'd guess that the splitter bar is just a semi-transparent filled rectangle.
However, GDI has fairly poor support for transparency.
You could get the same effect using a semi-transparent, always-on-top, layered window. This is a simple solution because you don't have to worry about repainting anything. You just move the window about.
This answer to another question has some code that creates such a window (for a different purpose).
This is probably one of the correct uses for LockWindowUpdate().
On Mousedown, lock the window, and start drawing the drag bar directly. As the mouse is still captured, the drag bar will still receive mouse notification. On mouseup, unlock the window, resize and let the drawing carry on as normal.

How can I draw around a rectangle?

I'm using openGL to draw some animation.
I want to draw the animation in an area around a rectangle.
That rectangle are should be transparent, to show whatever windows happen to be there, and leave that to regular windows MFC drawings.
I know there should be away to do it with clipping. But since whatever is in that rectangle isn't drawn with the openGL I'm not sure that will work well.
I'm using openGL with c++.
Solution:
If you are drawing over unrelated windows, you should use Stencil buffer.
This can be used as a masking layer to decide where you want to draw.
If you have an MFC window with a child window, you can create the "father" window with the following style: WS_CLIPCHILDREN

How to intercept mouse events of a transparent window?

I have a transparent window (created with WS_EX_LAYERED) and I'd like to receive mouse events of the zero-alpha regions.
As far as I know, I could:
1) Use mouse hook
2) Paint the background with almost completely transparent color (that has an opacity of 1)
However, the first solution is time consuming and the 2nd one will slow my rendering time as my window is stretched almost all over the desktop and most of the pixels are completely transparent at the moment.
Is there another way receiving those mouse events?
According to MSDN:
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.
However, in a new thread you could get continuously the coordinates of the mouse with GetCursorPos and if the position is inside one of your icons (regardless, that it's over a zero alpha pixel inside the icon) you handle it. Not too much better than the hook

Making non pop-up window transparent in mfc

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.