Leaders snarfblam Posted April 28, 2005 Leaders Posted April 28, 2005 I have a control that I want to be hidden when the user clicks outside of it. How can I detect such a mouse click? Quote [sIGPIC]e[/sIGPIC]
Rothariger Posted April 28, 2005 Posted April 28, 2005 i think you must explore the mousepointer.x or y, and with the window position and size of it... but i dont know... Quote
IngisKahn Posted April 28, 2005 Posted April 28, 2005 If the control receives focus then you can use the LostFocus event. Quote "Who is John Galt?"
Leaders snarfblam Posted April 28, 2005 Author Leaders Posted April 28, 2005 If the control receives focus then you can use the LostFocus event. Well... that's what I tried. The problem is that my form is full of pictureboxes, which react to mouse events, but don't take focus. Quote [sIGPIC]e[/sIGPIC]
*Experts* DiverDan Posted April 28, 2005 *Experts* Posted April 28, 2005 One thought would be to have your form detect the mouse click then send a delegated message via a public properity to the control. Quote Member, in good standing, of the elite fraternity of mentally challenged programmers. Dolphins Software
Leaders snarfblam Posted April 29, 2005 Author Leaders Posted April 29, 2005 One thought would be to have your form detect the mouse click then send a delegated message via a public properity to the control. The control would need to be hidden not only when the user clicks on the form, but when he clicks on any other control, even those that can't accept focus, as well as when the user clicks anywhere outside the form. I wanted my control to act very much like a context menu, in that when you click a button, it is displayed, allows him to make a selection (from a grid, thought, rather than a list of menuitems), then the control would disappear. And, like a menu, if the user clicks anywhere else on the screen, I want to hide the control and get it out of his way. What I did is show a context menu with a single, owner drawn item. I do my drawing to the menuitem instead of a control, and when the user clicks, I take the mouse coordinates, and calculate where in the menu the user clicked. This method, however, gives me less control with respect to mouse events, and is less reliable. Quote [sIGPIC]e[/sIGPIC]
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.