gpt4 book ai didi

delphi - 如何使鼠标悬停在“最小化”、“最大化”和“关闭”按钮上时表现良好?

转载 作者:行者123 更新时间:2023-12-03 14:34:24 26 4
gpt4 key购买 nike

在 Delphi 应用程序中,当您将鼠标悬停在边框图标上时,例如:

  • 最小化
  • 最大化
  • 恢复

它的行为不正确:

enter image description here

与行为正确的应用程序进行比较:

enter image description here

重现步骤

  1. 单击文件新建VCL 表单应用程序 - Delphi
  2. 点击运行 (F9)
  3. 将鼠标悬停在“最小化”、“最大化”或“关闭”按钮上。

如何解决?

  • Windows 10,64 位(在台式电脑上本地运行)
  • 德尔福XE6

编辑 - Delphi 7 也失败:

enter image description here

在 Delphi 5 中:

enter image description here

在 Delphi 4 中:

enter image description here

我假设(即害怕)这是由 ThemeServices 引擎引起的;他们可能认为不尊重用户的偏好很酷。但看起来这是更基本的东西。

兼容模式

  • :失败
  • Windows 8:失败
  • Windows 7:失败
  • Windows Vista (Service Pack 2):失败
  • Windows Vista (Service Pack 2):失败
  • Windows Vista:失败
  • Windows XP (Service Pack 3)(禁用非客户区主题):有效
  • Windows XP (Service Pack 2)(禁用非客户区主题):有效
  • Windows 98/Windows Me(禁用非客户区主题):有效
  • Windows 95(禁用非客户区主题):有效

Skype

在 Skype 中也失败;也是用 Delphi 编写的:

enter image description here

高 DPI 是触发器

我终于明白了为什么它在我使用过的每台 Windows 10 机器上都失败了;但并不适合所有人。高 dpi。

将 dpi 设置为 97 (101%) 或更高。

足够接近

Dalija 的解决方案有效:

enter image description here

我们将忽略工具提示的问题并继续战斗。

还应该注意的是,Windows 10 会建议您可能必须注销并重新登录,某些应用程序才能在更改 DPI 后正常工作。 Delphi 确实如此。

还应该注意的是,Delphi 不能容忍 DPI 像这样在背后改变。这包括调整缩放 slider 。这还包括将应用程序放置在主显示器之外的任何显示器上。

我们从来没有弄清楚问题出在哪里;只是为运行多个显示器的用户提供了便利。

质量控制错误报告

因为 Bor...Impr...CodeG...Embarca... Idera 的 QC 站点位于付费墙后面,这里有 bug report: 的副本

如您所见:没人关心。

最佳答案

高 DPI 是触发因素,它会带来解决方案。

出现此问题的应用程序无法识别高 DPI。解决悬停问题的方法是使用 1、2 或 3 中的解决方案之一让他们意识到或打开关联的兼容模式。

注意:打开高 DPI 感知时应用程序的其余部分是否会正常运行是另一个问题,并且因应用程序而异。

  1. 在兼容模式下选中“在高 DPI 设置下禁用显示缩放”

  2. 调用 SetProcessDPIAware 作为 .dpr 文件中的第一次调用 - 正如 Ian Boyd 所指出的,调用此函数可能会导致竞争条件,首选方法是使用 list 。 SetProcessDPIAware

  3. 使用带有 truetrue/PM 设置的自定义 list (“启用运行时主题”中包含的默认 Delphi list 不支持高 DPI)

当前版本的 Delphi VCL 和 FMX 框架缺乏对每个显示器 DPI 感知的支持,因此仅当您自己处理每个显示器 DPI 时才使用 true/PM list 。向 QP 报告为 VCL and FireMonkey lack Per-Monitor DPI support for Windows 8.1 (and Windows 10)

<小时/>
  <asmv3:application>
<asmv3:windowsSettings xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">
<dpiAware>true</dpiAware>
</asmv3:windowsSettings>
</asmv3:application>

  <asmv3:application>
<asmv3:windowsSettings xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">
<dpiAware>true/PM</dpiAware>
</asmv3:windowsSettings>
</asmv3:application>
<小时/>

更新:

Delphi VCL 是错误行为的根源,具体问题出在 TForm 类或其祖先中的某个位置。当使用直接 Windows API 时,窗口会正常运行。

行为正常的 Windows API 代码:

  MessageBox(0, 'Correct', 'Caption', MB_OK); 

ShowMessage('Correct'); // if themes are enabled -> Windows Task dialog is used

不使用 VCL 创建主窗口的完整 Delphi 示例应用程序 - 行为正常

program win;

{$R *.res}

uses
Windows,
Messages,
SysUtils;

var
Msg: TMSG;
LWndClass: TWndClass;
hMainHandle: HWND;

function WindowProc(HWND, Msg: Longint; wParam: wParam; lParam: lParam): Longint; stdcall;
begin
if Msg = WM_DESTROY then PostQuitMessage(0);
Result := DefWindowProc(HWND, Msg, wParam, lParam);
end;

begin
LWndClass.hInstance := hInstance;
with LWndClass do
begin
lpszClassName := 'WinApiWnd';
Style := CS_PARENTDC or CS_BYTEALIGNCLIENT;
hIcon := LoadIcon(hInstance, 'MAINICON');
lpfnWndProc := @WindowProc;
hbrBackground := COLOR_BTNFACE + 1;
hCursor := LoadCursor(0, IDC_ARROW);
end;

RegisterClass(LWndClass);
hMainHandle := CreateWindow(LWndClass.lpszClassName, 'Window Title', WS_CAPTION or WS_MINIMIZEBOX or WS_SYSMENU or WS_VISIBLE, 0, 0, 360, 200, 0, 0, hInstance, nil);

while GetMessage(Msg, 0, 0, 0) do
begin
TranslateMessage(Msg);
DispatchMessage(Msg);
end;
end.

行为不当的 VCL 表单:

var
f: TForm;

f := CreateMessageDialog('Broken', mtWarning, mbOKCancel, mbOk);
f.ShowModal;
f.Free;

f := TForm.Create(nil);
f.ShowModal;
f.Free;

关于delphi - 如何使鼠标悬停在“最小化”、“最大化”和“关闭”按钮上时表现良好?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31630280/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com