C++ Layered Window and WM_MOUSEMOVE

932 views Asked by At

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

There are 1 answers

0
Adrian McCarthy On

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.