在DLL中使用VCL样式会在10.2 Tokyo中导致系统异常 [英] Using VCL Styles in a DLL causes System Exception in 10.2 Tokyo

查看:159
本文介绍了在DLL中使用VCL样式会在10.2 Tokyo中导致系统异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最初用XE2编写的应用程序,它使用DLL内的样式,以便从DLL弹出的窗体与EXE的样式相同,在更新为在10.2 Tokyo中生成时,现在从EXE打开某些窗体时会导致系统异常,或者在EXE中关闭某些表格时.

解决方案

我不需要包含最小可重复示例,因为我有一个答案,所以如果没有迅速关闭该问题,即使在进行主题讨论后也没有重新打开,也许其他人也可以添加到我的原始问题中./p>

原来这是VCL中的行为问题:

如果以驻留在DLL中且使用VCLStyles的形式使用组合框,则发生异常. a>

Embarcadero无法解决它,因为它不是一个问题",

R& D写道,必须在应用程序中启用样式管理器 并且只有一个启用了系统挂钩的TStyleManager (TStyleManager.SystemHooks属性),因为它处理所有窗口 从应用程序.当前系统不支持您的方案 正在提示,并且目前没有计划对其进行返工

,但是有一种解决方法是在DLL代码中调用 SetStyle TrySetStyle 之前立即添加以下代码:

TStyleManager.SystemHooks := [];

希望这将对在升级到新版本后遇到此烦人问题的Delphi开发人员有所帮助.

对于我来说,我将条件定义添加到库的项目中,然后将此代码添加到设置样式的位置,因为EXE和DLL中都包含相同的单元:

{$IFDEF DLL}
  TStyleManager.SystemHooks := [];
{$ENDIF}

An application originally written in XE2 that uses styles within DLL's so that forms that popup from DLL's are the same style as the EXE, when updated to build in 10.2 Tokyo, now causes System Exceptions when opening certain forms from the EXE, or when closing certain forms in the EXE.

解决方案

I don't need to include the minimal reproducible example in this question, because I have an answer, that someone else may have been able to add to my original question had it not been closed so quickly, and then not re-opened even after making it on-topic.

Turns out it's a behavioural issue in VCL:

Exception if using comboboxes in a form that resides in a DLL and that uses VCLStyles.

Embarcadero won't fix it as it's not a "problem",

R&D writes that the style manager has to be enabled in the application and there can be only one one TStyleManager with enabled system hooks (TStyleManager.SystemHooks property), because it process all windows from application. The current system doesn't support the scenario you are suggesting, and there is currently no plan to rework it

but there is a workaround which is to add the following line of code immediately before calling SetStyle or TrySetStyle in the DLL code:

TStyleManager.SystemHooks := [];

Hopefully this will be of assistance to Delphi developers who run into this annoying problem after upgrading to the newer versions.

In my case, I add a conditional define to the project for the libraries, then add this code to the places where it setting styles, as the same unit is included in both EXE and DLL:

{$IFDEF DLL}
  TStyleManager.SystemHooks := [];
{$ENDIF}

这篇关于在DLL中使用VCL样式会在10.2 Tokyo中导致系统异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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