【发布时间】:2016-12-08 18:22:23
【问题描述】:
我注意到在一些 Windows 更新后,我在 Delphi 7 中制作的应用程序不再正确聚焦。标题栏不会改变颜色。按钮、滚动条等 UI 元素不会做出反应。我也无法使用标题栏按钮最小化或关闭表单。
奇怪的是,我仍然可以通过拖动标题栏来移动表单,而且程序总体上运行良好。
这是一个显示正在发生的事情的动画:
以下是我测试过的 Windows 版本列表:
Windows 7 SP1 + updates -> OK!
Windows 8.1 without updates -> OK!
Windows 8.1 with all updates -> NO FOCUS!
Windows 10 BUILD 10240 -> OK!
Windows 10 BUILD 10586 -> OK!
Windows 10 BUILD 14393 -> NO FOCUS!
我尝试使用以下代码禁用窗口重影:
var
User32: HMODULE;
DisableProcessWindowsGhosting: TProcedure;
begin
User32 := GetModuleHandle('USER32');
if User32 <> 0 then
begin
DisableProcessWindowsGhosting := GetProcAddress(User32, 'DisableProcessWindowsGhosting');
if Assigned(DisableProcessWindowsGhosting) then
DisableProcessWindowsGhosting;
end;
end;
另外,我删除了所有 Application.ProcessMessages() 调用,但仍然没有任何变化。
【问题讨论】:
-
那段代码是关于什么的。看起来你的程序坏了,你的解决办法是把头埋进沙子里。
-
所有线程仅通过同步访问 UI 元素。我很清楚,直接从线程访问 UI 只是灾难的收据。 Microsoft 必须通过发生此问题的一些更新来更改某些内容。它多年来一直运行良好,现在 BAM!
-
为什么需要禁用重影。你犯了什么暴行。
-
因为我发现了这个主题stackoverflow.com/questions/743713/…,我只是好奇该案例的解决方案是否会有所帮助。
-
你的代码可能有缺陷
标签: delphi