如何在Delphi中执行此操作:
procedure ToggleVisibility(ControlClass : TControlClass);
var
i : integer;
begin
for i := 0 to ComponentCount - 1 do
if Components[i] is ControlClass then
ControlClass(Components[i]).Visible := not Control(Components[i]).Visible;
end;
Run Code Online (Sandbox Code Playgroud)
在这种情况下,编译器不允许强制转换.有任何想法吗?
我正在使用Delphi 2007.
我在Delphi 2007中编写了应用程序,有时会挂起(甚至不是每周都有应用程序全天候运行).看起来主线程卡住了.有哪些方法可以找出导致此问题的原因?
应用程序是用Delphi 2007编写的,它使用RemObjects,DBExpress和Firebird,使用COM进行OPC通信.
有时在Delphi 2009调试器下运行应用程序时,只要我对应用程序表单执行任何操作(单击,移动..)Delphi就会开始使用以下消息来填充事件日志(类似):
Module Load: UNKNOWN_MODULE_59954.No DebugInfo. Base Address: $02D90000. Process MyApp.exe (5584)
Module Unload: UNKNOWN_MODULE_59954. Process MyApp.exe (5584)
Run Code Online (Sandbox Code Playgroud)
每个循环的UNKNOWN_MODULE数量增加,因此例如已经有近60000个模块加载/卸载.
在洪水期间,申请仍然没有响应.有时我必须终止应用程序才能继续.
知道如何开始跟踪原因吗?
我在FastMM和FullDebugMode打开的情况下测试了我的应用程序,因为我遇到了一些关机问题.
在解决了我自己的问题之后,FastMM开始抱怨在TPopupList中对释放的对象调用虚方法.我试图在使用中尽早移动菜单单元,以便最后确定,但它没有帮助.这是真正的问题,来自FastMM的vcl或虚假警报中的错误?
以下是FastMM的完整报告:
FastMM has detected an attempt to call a virtual method on a freed object. An access violation will now be raised in order to abort the current operation.
Freed object class: TPopupList
Virtual method: Offset +16
Virtual method address: 4714E4
The allocation number was: 220
The object was allocated by thread 0x1CC0, and the stack trace (return addresses) at the time was:
403216 [sys\system.pas][System][System.@GetMem][2654]
404A4F [sys\system.pas][System][System.TObject.NewInstance][8807]
404E16 [sys\system.pas][System][System.@ClassCreate][9472]
404A84 [sys\system.pas][System][System.TObject.Create][8822]
7F2602 [Menus.pas][Menus][Menus.Menus][4223]
40570F [sys\system.pas][System][System.InitUnits][11397]
405777 [sys\system.pas][System][System.@StartExe][11462]
40844F …Run Code Online (Sandbox Code Playgroud)