如何防止形式焦点丢失? [英] How to prevent form focus loss?

查看:130
本文介绍了如何防止形式焦点丢失?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好!

我有两种形式:表格A和表格B:



http://ib3.keep4u.ru/b/2013/06/13/66/66de96e869ae82bf7e549e1d0603e51b .jpg [ ^ ]



- 形式A的样式是fsStayOnTop - 在所有窗口之上;

- B形式的风格也是fsStayOnTop - 在其父母的所有窗口之上。



当我点击表格A - 形式B 没有失去焦点 - 这很好。

问题:当点击表格A之外时,表格B失去了焦点(隐藏在A形式后面) - 这实际上是是问题。



告诉我如何解决这个问题?我需要:当我点击A形式之外时,表格B必须保持在原始位置(高于图片中A形式)。

解决方案

我认为实现这一目标的唯一可靠方法是使B成为A的孩子,这意味着它不能出现在A的客户区域之外,并且总是在A之上绘制。否则你就是与窗口管理器和用户进行战斗,这是一场你将要放松的战斗。



这就是假设您在Microsoft Windows上工作并且这些表格都是完全合格的Windows窗口不是WPF假窗口或类似的东西。


您打算在打开表单B时从表单A中删除fsStayOnTop选项并在B关闭时读取它吗?

Hello!
I have two forms: form "A" and form "B":

http://ib3.keep4u.ru/b/2013/06/13/66/66de96e869ae82bf7e549e1d0603e51b.jpg[^]

- the style of the form "A" is "fsStayOnTop" - on top of all windows;
- the style of the form "B" is also "fsStayOnTop" - on top of all windows of its parent.

When I click on form "A" - form "B" does not lost focus - it's good.
Problem: when clicking outside of the form "A", the form "B" lost its focus (is hiding behind the form "A") – this actually is the problem.

Tell me how to solve the problem? I need: when I click outside of the form "A", form "B" must be remained at its original position (higher than form "A" like in the picture).

解决方案

I think the only reliable way to achieve this is to make "B" a child of "A" meaning that it cannot appear outside the client area of A and always get painted on top of A. Otherwise you're fighting both the the window manager and the user and that is a battle you're going to loose.

This is all assuming your working on Microsoft Windows and these forms are fully qualified Windows windows not WPF fake windows or something of that sort.


Have you considered removing the fsStayOnTop option from form A when opening form B and readding it when B is closed?


这篇关于如何防止形式焦点丢失?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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