- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我在遇到以下情况时遇到问题:
表单关闭后,Edit2上的焦点似乎“崩溃”了......- 未选择 Edit2 中的孔文本- 插入符不闪烁
示例:
在 Edit1 中将其设置为 OnExit 事件:
procedure TForm1.Edit1Exit(Sender: TObject);
begin
with TForm.CreateNew(self) do
try
Width := 100;
Height := 50;
Position := poMainFormCenter;
show;
sleep(200);
finally
Free;
end;
end;
运行应用程序
我正在使用:
最佳答案
这是一个已知问题。当您在完成最后一次焦点更改之前更改焦点时,Windows 会出现问题(例如,焦点开始从 Edit1
更改为 Edit2
,但 Edit1.OnExit
) > 执行某些操作将焦点更改为另一个控件或表单。
例如,当应用尝试在 OnExit
事件中进行验证,然后在验证失败时尝试将焦点返回到原始控件时,就会发生这种情况。
最简单的解决方案是在 OnExit
中向表单句柄发布消息,并在那里处理焦点更改需求。一旦目标控件获得输入焦点,它将触发,并且 Windows 不会感到困惑。
const
UM_EDIT1_EXITED = WM_USER + 1;
type
TForm1=class(TForm)
...
private
procedure UMEdit1Exited(var Msg: TMessage); message UM_EDIT1_EXITED;
end;
implementation
procedure TForm1.Edit1Exit(Sender: TObject);
begin
PostMessage(Handle, UM_EDIT1_EXITED, 0, 0);
end;
procedure TForm1.UMEdit1Exited(var Msg: TMessage);
begin
// Show your other form here
end;
摘自 Peter Below 博士的旧 Borland NG 帖子 TeamB :
here is my general sermon on the "show dialog from OnExit" problem:
If an OnExit handler is triggered (which happens in response to the Windows message WM_KILLFOCUS) Windows is in the midst of a focus change. If you do something in the handler that causes another focus change (like popping up a message box or doing a SetFocus call) Windows gets terribly confused. The missing cursor is a symptom of that.
If you have to display a message to your user from an OnExit handler, do it this way:
Define a constant for a user message somewhere in the INterface section of your unit, above the type declaration for your form
'Const UM_VALIDATE = WM_USER + 200;'
Give your Form a handler for this message, best placed in the private section of the class declaration:
Procedure UMValidate( Var Msg: TMessage ); message UM_VALIDATE;
Post a UM_VALIDATE message to the form from the OnExit handler if the contents of the field are not ok. You can pass additional information in the wparam and lparam parameters of the message, e.g. an error number and the Sender object. In fact you could do the whole validation in the UMValidate handler!
关于DELPHI Edit.OnExit 通过 TAB,在焦点上显示窗口结果 bug,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11155718/
当从一个屏幕导航到另一个屏幕时,必须调用 onExit 来释放资源。但是它没有被触发。这是我的代码: function (BaseController, JSONModel, formatter, F
我有两个状态,A 和 B。 当我通过单击关闭按钮退出状态 A 时,我使用 $state.go 转换到屏幕 A 到状态 B(屏幕 B) 当我通过单击屏幕 A 上的后退浏览器按钮退出状态 A 时,我会随着
我正在尝试创建一个线程,并在 wxPython 应用程序的框架关闭时结束它。这是我的代码: #! /usr/bin/env python import time, wx from threading
我在完成(退出)小部件时请求 URL 时遇到一些问题。我尝试根据请求通过 window.widget.onexit 使用它,然后使用注销 URL,这会在后端生成一些日志。我尝试了以下方法: windo
我目前正在测试来自 java 9 的 Process API,但我在使用以下代码时遇到了一些问题: Process process = new ProcessBuilder( List.of("pin
我是 android 新手,已经阅读了 Android app start and end event和 Android onClose event但还没有找到答案。 我正在开发一个简单的应用程序 -
我有代码: Private Sub TempCombo_Exit(Cancel As Integer) MsgBox "test" End Sub 但是当我从 TempCombo 退出时什么都
我在 openui5 中使用选项卡 Controller ,我想定期执行一些操作,所以我使用了下面的代码: sap.ui.jsview("oui5mvc.tabs", { getControl
我正在开发一个简单的应用程序来使用 Swing 管理业务的运营部分,但我需要在应用程序退出时执行以下操作: updateZonas(); db.close(); 但是我该怎么做呢? 最佳答案 Runt
我有一个 View 问题,该 View 显示一棵树与 SQLite 数据库建立了很多连接,并且只想建立一个。因此,我需要使用一些东西来控制它的生命周期,以便连接能够与 View 一起打开和关闭。 所以
我想在用户离开某个状态时在页面中的某个元素上显示动画。这是我目前拥有的: { ....., views: { ... }, onExit: function(){
我试图了解应该如何设计 WxWidgets (3.0.1) 应用程序,但我遗漏了一些东西,因为我正在尝试的东西不起作用。 在基本层面上,我有我的 WxApp,它创建了一个 WxFrame,它得到显示并
C# XNA 游戏是否有任何方法可以检测用户是单击十字按钮关闭程序,还是按下 ALT+F4 键关闭..? 可能可以从 KeyBoardState 检测到 ALT+F4 键,但是我如何检测到单击十字按钮
我有 Rectangle 填充了 MouseArea,它在 onPressAndHold() 处理程序上显示第二个 Rectangle 并传输 将 操作拖到那个Rectangle。问题是,当我将第二个
我在遇到以下情况时遇到问题: 2 编辑 在 Edit1 中输入内容并按 TAB 键,焦点将转到 Edit2 Edit1.OnExit -> 显示带有消息“正在处理...”的表单(进行冗长的验证) 表单
我在Experts-Exchange上发现了这个问题. Control's OnExit eats up mouseup event for new control when showing anot
我在Experts-Exchange上发现了这个问题. Control's OnExit eats up mouseup event for new control when showing anot
当我尝试在 Release模式下运行我的程序时,它会直接运行到 Unhandled exception at 0x6f2426ef (msvcr100.dll) in FPS Game.exe: 0x
onExited 回调不工作,onClose 工作正常,请帮我找出为什么会发生,是 material ui 上的问题> ,或者在我的代码中 ??我也尝试过使用 onMouseLeave 但它也不起作
我正在寻找以下可能性: $stateProvider.state('user', angularAMD.route({ url: '/user/:id', templa
我是一名优秀的程序员,十分优秀!