I think you will need to set the cover for the entire application, and if your panel is visible, and the coordinates of the mouse event are outside the borders of your panel, then hide the panel. Also process the WM_ACTIVATE message in your form.
[Edited: deleted response using SetCaptureControl (), because bahaviour is not suitable in this case)
source share