模拟外部单击弹出菜单 [英] Mimic outside click on a popup menu

查看:128
本文介绍了模拟外部单击弹出菜单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您知道如果在弹出菜单中单击菜单之外的弹出菜单会如何消失?好吧,我想重现这一点。

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.

推荐答案

我认为您需要安装和应用范围内的鼠标消息钩子,如果您的面板可见并且鼠标事件的坐标在面板范围之外,请隐藏该面板。

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.

这篇关于模拟外部单击弹出菜单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆