【问题标题】:How can I fix EInvalidOperation related to ImageList如何修复与 ImageList 相关的 EInvalidOperation
【发布时间】:2013-06-21 17:29:08
【问题描述】:

我的应用程序(在 Delphi 7 上编写)在 Windows XP SP3 上正常运行,但是当我尝试在 Windows 7 上运行它时出现此异常:

EInvalidOperation 带有消息“Invalid ImageList”

这是主要的应用程序代码:

  Application.Initialize;

  tmpSplash.GoNextMsg;
  Application.CreateForm(TdmImages, dmImages);

  tmpSplash.GoNextMsg; // Collegamento database
  Application.CreateForm(TdmCharter, dmCharter);


  tmpSplash.GoNextMsg; // Caricamento immagini
  Application.CreateForm(TfrMain, frMain);

  tmpSplash.GoNextMsg; // init: Anagrafica
  frameAnagrafica := TframeAnagrafica.Create(Application);

  tmpSplash.GoNextMsg; // init: Flotta
  frameFlotta := TframeFlotta.Create(Application);
  //Application.CreateForm(TframeFlotta, frameFlotta);

  ...
  ...

模块 dmImages 已经正确创建,例如 frMain,但是当 将创建对象 frameAnagrafica 然后在构造函数方法上引发异常:

type
    TframeAnagrafica = class(TMyCustomFrame)
...
...

{$R *.dfm}
constructor TframeAnagrafica.Create(AOwner: TComponent);
begin
  inherited Create(AOwner); 

end;

还有 TframeAnagrafica 的“超类”:

TMyCustomFrame = class(TFrame)
...
...

{$R *.dfm}

constructor TMyCustomFrame.Create(AOwner: TComponent);
begin
  inherited Create(AOwner); <-- Exception here

end;

在windows XP下没问题,但是用windows 7就出问题了。 我该如何解决这个问题?

【问题讨论】:

  • 也许你可以展示一些你的代码。否则,我们的帮助希望破灭。
  • 什么版本的Delphi?图像列表中有哪些类型的图像?它们是如何加载到图像列表中的?如果您希望我们为您提供帮助,您需要具体并提供详细信息。我们无法从这里看到您的代码、读懂您的想法或访问您的机器来为您调试它,因此我们所能做的就是使用您提供给我们的信息来提供帮助。请edit您的问题并提供更多信息。谢谢。
  • 你在问我们什么?
  • 应用程序清单可能有问题。
  • 我注意到您编辑了问题。你这样做很好,但在你提供一些真实信息之前你不会得到任何帮助。解决问题不是靠魔术发生的。收集信息和证据。然后可以制定解决方案。你需要做得更好。

标签: delphi delphi-7 timagelist


【解决方案1】:

如果您使用当前操作系统不支持的属性 ColorDepth 的值,则可能会发生此类异常。或者,如果您尝试使用带有 alpha 通道 (TColorDepth.cd32Bit) 的 32 位图像列表,但您的应用程序中没有 XP 清单,则可能会发生这种情况。为此,请在您的项目中包含单元 xpman 或在 Delphi XE2 或更高版本的“项目 > 选项 > 应用程序 > 外观 > 运行时主题”中选择“启用运行时主题”。

【讨论】:

  • 我试图删除主窗体上的控件 XPManifest 并且应用程序运行正确。
  • 比删除 XP 清单更好的是让图像列表与 XP 及更高版本兼容。没有 XP 清单会导致某些库在 Windows 2000 版本中加载并且主题将被关闭。
【解决方案2】:

我刚刚收到来自 Windows 10 的更新,它弄乱了我的机器,夺走了我的文件夹的权限。我目前正在运行 Delphi,当我尝试打印报告时,我收到错误消息 Class Elnvalidoperation 无法生成报告。这是因为我的打印机不见了,我不得不重新安装,问题似乎已经解决了。

【讨论】:

    猜你喜欢
    • 2018-04-29
    • 2020-01-02
    • 2017-04-05
    • 1970-01-01
    • 2021-02-20
    • 2012-02-07
    • 2021-09-25
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多