1
votes

I'm trying to make a transparent screensaver in C++ and WinAPI.

It works fine so far on Windows XP, but on WES7 I have the following problem: By making my screen transparent, I can't recieve any WM_MOUSMOVE messages.

SetWindowLongPtr( hWnd,
           GWL_EXSTYLE,
           GetWindowLongPtr(hWnd, GWL_EXSTYLE) | WS_EX_LAYERED | WS_EX_TOOLWINDOW );
double TransparencyPercentage = 50.0;
double fAlpha = TransparencyPercentage * ( 255.0 /100 );
BYTE byAlpha = static_cast<BYTE>( fAlpha );
SetLayeredWindowAttributes( hWnd, 0, byAlpha, LWA_ALPHA );

I already got the information, that byAlpha has to be bigger than 0, because I won't recieve any mouse messages otherwise, but I still recieve keyboard messages, as well as mouseclicks.

Hope you can help me with this.

1
I scavenged a quick test just creating a layered window and looking for WM_MOUSEMOVE and it worked fine. Does this code work properly?chris
actually im working on WES 7, but i guess that WES 7 is based on Windows 7 and so its basics should be just the same, shouldnt they?user2618639
Yes chris, your code is workinguser2618639
WM_MOUSEMOVE messages are only generated if the message queue is empty. If you are posting lots of messages you may never fully deplete the message queue to have a WM_MOUSEMOVE message generated the next time you call GetMessage.IInspectable
Transparent windows are transparent to the user's eyes and to the mouse. Mouse messages go where the user thinks they'll go. You can't change that. What's different in Win7 is Aero, it does layered windows differently.Hans Passant

1 Answers

0
votes

Since this is a screen saver, I assume you need the WM_MOUSEMOVE to know when to quit. You can use SetCapture to have all mouse input sent to your window regardless of where it actually points.