mfc >> WS_EX_LAYERED and WM_MOUSEMOVE

by newsposter » Tue, 21 Mar 2006 07:45:51 GMT

I need to capture mouse events for a semi-transparent window. However,
mouse events are never received by this window. I read MSDN (hit test
with transparency) but it is not clear what to do. I need to receive
WM_MOUSEMOVE with a semi-transparent window.

First I call...

::SetWindowLong(hWnd, GWL_EXSTYLE, ::GetWindowLong(hWnd, GWL_EXSTYLE) |
WS_EX_LAYERED);

Then I call the GetProcAddress(..., "SetLayeredWindowAttributes");

The transparency works fine, but the dialog doesn't receive mouse
events.

Anyone know how?

Thanks,
Chris



mfc >> WS_EX_LAYERED and WM_MOUSEMOVE

by AliR. » Tue, 21 Mar 2006 09:42:28 GMT


I am not aware of any problems with the WM_MOUSEMOVE on a Layered
window.

I just tested this with Visual Studio 2005 on an XP system.

BEGIN_MESSAGE_MAP(CMyDialog, CDialog)
ON_WM_MOUSEMOVE()
END_MESSAGE_MAP()

BOOL CMyDialog::OnInitDialog()
{
CDialog::OnInitDialog();

SetWindowLong(m_hWnd, GWL_EXSTYLE, GetWindowLong(m_hWnd,
GWL_EXSTYLE) | WS_EX_LAYERED);

SetLayeredWindowAttributes(0,150,LWA_ALPHA);

return TRUE;
}

void CMyDialog::OnMouseMove(UINT nFlags, CPoint point)
{
MessageBeep(1);

CDialog::OnMouseMove(nFlags, point);
}

and all the WM_MOUSEMOVE messages that belong to the dialog were being
received by the dialog.

AliR.




mfc >> WS_EX_LAYERED and WM_MOUSEMOVE

by newsposter » Tue, 21 Mar 2006 22:56:37 GMT

Thanks AliR... I created a new dialog using some template code and it's
working now. There must have been something that the other dialog was
doing wrong.
-Chris



Similar Threads

1. SetWindowLong and WS_EX_LAYERED makes Windows invisible,...

2. RectVisible doesn't work with WS_EX_LAYERED style

3. WS_EX_LAYERED but catching mouse messages

4. Ned help with marshaling (SendMessage, lparam, WM_MOUSEMOVE)

Hello,

I need some help with the SendMessage method. I've imported it into C# with 
the following statement:

[DllImport("user32.dll", SetLastError=true)]

public static extern IntPtr SendMessage(IntPtr hWnd, int Msg, long wparam, 
int lparam);

and the following for sending the message:

User32.SendMessage(WindowObject_Basic_GDI_Handle, User32.WM_MOUSEMOVE, 
User32.MK_LBUTTON, MakeLParam(X, Y));

and below for constructing the lparam:

private int MakeLParam(int LoWord, int HiWord)


{

//System.Diagnostics.Debug.WriteLine("LoWord: " + LoWord2(((HiWord << 16) | 
(LoWord & 0xffff))));

return (int) ((HiWord << 16) | (LoWord & 0xffff));


}

Unfortunately, whenever I send a WM_MOUSEMOVE message to a window 
(Notepad.exe), the lparam parameter doesn't mike it there!

Spy++ reports X and Y coordinates of 0. (Everything else makes it there ok).

Does anyone have ideas what kind or marshaling I need to do, or if I am 
sending the correct data?

Thanks,

Ryan


5. Problem in Text Selection through Mouse, when I use WM_MOUSEMOVE

6. Disabling WM_MOUSEMOVE messages

Hi,

I use the following loop for my game:

////////////////////////////////////////
 MSG msg;
 long iNewTime = 0;
 long iTickCount;

while (true)
 {
        if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
       {
               if (msg.message == WM_QUIT)
                    break;

               TranslateMessage(&msg);
               DispatchMessage(&msg);
       }
        else
       {
               iTickCount = GetTickCount();
               if (iTickCount > iNewTime)
               {
                    iNewTime = iTickCount + REFRESH_TIME;

                    Event();    //do things in the game
               }
        }
 }
/////////////////////////////////////

But whenever I move my mouse, the frame rate reduces significantly.
I think it's because too many WM_MOUSEMOVE messages are generated.

So is there a way to prevent the application from generating WM_MOUSEMOVE?

Thanks,
Nelson

PS. My application is on Pocket PC and I'm using eVC4.


7. WM_MOUSEMOVE notifications

8. Unexpected WM_MOUSEMOVE after double click in list control

Hello

I have a view with two child windows. One of them is a list control
and the other is a CWnd derived class (my own control).
Both list and my control have the same size and position but
only one of them is visible at the time.

For example, when I double click the list item the list hides itself
and my control shows up.
All this happens inside WM_NOTIFY event handler (NM_DBLCLK).


So the list of events goes like this:
- double click event handler goes off
- list hides itself
- my control shows up
(here's the end of NM_DBLICK event handler call)
- on mouse move event handler goes off in my control

This on mouse move event is unexpected since I only double clicked the 
list. Is there a way to stop this event from being sent at all?

Thanks
si