0

Is it possible for the entire bounds of a form to be hittest transparent without adjusting the visibility of the form?

I am using a user32 api call to WindowFromPoint in order to find the control under the mouse. In some circumstances I would like to ignore the existance of a child form that floats in front of the main form (or another child form), but keep this form to ignore visible.

Setting the Opacity of the form to ignore to 0 will successfully cause the hittest to pass straight through it, but the form obviously is invisible, and I'd prefer it to remain visible.

Since this child form can have any arbitrary number of controls on it, is there a way for this form intercept all WM_NCHITTEST messages going to child controls on the form so that I can return hittest transparency for each control? The controls contained on the form are arbitrary so I am unable to modify them internally.

roken
  • 3,946
  • 1
  • 19
  • 32
  • Have you tried overriding the WndProc method in the form where you want to capture the message? if that doesn't work then you could use a MessageFilter, more info: http://social.msdn.microsoft.com/Forums/en/netfxbcl/thread/7bd3e24f-c21c-4490-910d-b47b6becf70d – Sebastian Piu Jun 16 '12 at 18:24
  • What are the actual rules that you want to apply for the filtering? See: http://msdn.microsoft.com/en-us/library/ms158404.aspx – Emond Jun 16 '12 at 18:27
  • @Emo I'm hittesting for one form from another, not for a child control of the form, thus the win32 api call. – roken Jun 16 '12 at 20:15
  • @SebastianPiu Overriding WndProc in the form will only disable a hittest response for the form area itself, and not for any of the child controls on the form, so you can still end up hitting something on the form. The MessageFilter looks like it might be what I'm looking for, I take a look at it in more detail. – roken Jun 16 '12 at 20:17
  • @SebastianPiu it appears that WM_NCHITTEST bypasses the message queue and is sent straight to the control, thus a message filter doesn't get the opportunity to deal with it. – roken Jun 16 '12 at 21:47

1 Answers1

1

You are looking for the WS_EX_TRANSPARENT Windows Style.

This answer gives a good-enough explanation.

Community
  • 1
  • 1
John Arlen
  • 6,539
  • 2
  • 33
  • 42