views:

45

answers:

1

You know how in a popup menu if you click outside of the menu the popup disappears? Well I would like to reproduce that.

Currently I am having a panel created with some components on it when a button is clicked. The panel and sub components go away when you click a certain button on the panel. However I want it to go away if you click anywhere outside of the panel.

A: 

I think you would need to install and application-wide mouse message hook, and if your panel is visible and the coordinates of the mouse event are outside of your panel bounds, then hide the panel. Also handle the WM_ACTIVATE message in your form.

[Edited: removed answer involving SetCaptureControl() because the bahaviour is not appropriate in this circumstance]

avenmore