0

Very similar question here, but seems to be unanswered.

I have have implemented a shadowed window using two windows, one parent window which has the shadow but the main native window is the child window. The only problem is that my parent window is much bigger than the child window, and is using transparency to do a shadow. This makes my window handle mouse events even when I click in the shadow region.

enter image description here

What I want is to make my window lose focus whenever I click in the shadow (parent) region, similar to just clicking on another window that is not part of my application. I also want direct control of the location of this click through region, in the case of the shadow size changing.

How can I achieve this?

Thank you in advance.

Community
  • 1
  • 1
kir
  • 581
  • 1
  • 6
  • 22

1 Answers1

0

In the parent window, handle the WM_MOUSEACTIVATE message and return MA_NOACTIVATE to prevent a click on the parent window from activating it.

You'll also have to handle the message in the child window, and this time return MA_ACTIVATE.

Jonathan Potter
  • 36,172
  • 4
  • 64
  • 79
  • Will that make the mouse events be redirected to others window beneath the shadow? – manuell Dec 29 '13 at 11:56
  • Thanks! I will try this when I get home. – kir Dec 29 '13 at 12:04
  • 1
    `MA_NOACTIVATEANDEAT` will swallow the click and stop something else getting it. – Jonathan Potter Dec 29 '13 at 12:37
  • @JonathanPotter: it doesn't seem to work. Any idea on what's wrong? I'm handling it just after WM_CREATE and is handled on top of all other messages. [Here](https://gist.github.com/kirasagi/8170930) is a gist of my wndProc if you don't mind looking. – kir Dec 29 '13 at 14:31