单击表单上的任意位置时如何激活表单?
我的 C# 应用程序运行良好,并且在需要时始终保持领先。我面临和想要的是:
假设我的应用程序打开,另一个应用程序(比如记事本)也打开,与我的应用程序窗口半重叠。当我们单击记事本上的任意位置时,它就会被激活。而对于我的应用程序,我必须单击窗口的顶部栏才能将其激活。为什么会这样呢?我想让我的应用程序处于活动状态,并在用户单击表单上的任意位置而不仅仅是顶部栏时将其置于前面。
我需要设置或实施什么来实现这一目标?
MY C# app workd fine and stays on top whenever asked to. What I face and want is :
Suppose my app is open and another app (say Notepad) is also opened halfly overlapping my app window. When we click anywhere on Notepad, it gets activated. Whereas with my app, I got to click the top bar of the window to make it active. Why so ? I want to make my app active and bring to front when user clicks anywhere on the form and not just hte top bar.
What do I need to set or implement to accomplish this ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
尝试这样做,在 Form1_MousClick 事件上放置此代码
Try to do that ,on Form1_MousClick Event put this Code
没什么,如果您单击窗口上的任意位置,它就会获得焦点并成为最上面的窗口,除非另一个窗口“始终位于顶部”。
Nothing, if you click anywhere on a Window, it gets focus and becomes the topmost window, unless another window is 'Always on top'.
问题在于重写 WndProc。删除了一项不必要的声明,事情得到了解决。感谢大家的努力。
The problem was with overridding WndProc. One unnecessary statement was removed and things got solved out.Thanks to all of you for your efforts.