gpt4 book ai didi

delphi - EReadError - 当我尝试创建 Delphi 单元时属性值无效

转载 作者:行者123 更新时间:2023-12-02 12:40:05 27 4
gpt4 key购买 nike

我正在尝试创建并运行新的 Delphi 应用程序。但在下面的项目文件中,当我尝试 CreateForm: Debugger Exception: Project ... 引发异常类 EReadError 并显示消息 Invalid property value 时,出现此错误。进程停止。

program Project1;

uses
Forms,
OCR in 'OCR.pas' {Form1};

{$R *.res}

begin
Application.Initialize;
Application.Title := 'OCR';
Application.CreateForm(TForm1, OCR1);
Application.Run;
end.

单位:

unit OCR;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs;

type
TForm1 = class(TForm)
private
public
procedure FormCreate(Sender: TObject);
end;

var
OCR1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
var list: TStringList;
begin
list := TStringList.create;
list.loadFromFile('OCR.txt');

end;

end.

DFM 文件:

object Form1: TForm1
Left = 210
Top = 181
Width = 544
Height = 375
Caption = 'Form1'
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = []
OldCreateOrder = False
OnCreate = FormCreate
PixelsPerInch = 96
TextHeight = 13
end

我尝试运行 FormCreate 函数。我所做的是在“对象检查器”->“Form1”...“事件”...中设置了 OnCreate: FormCreate。这是在 Delphi 7 上创建的。这里有什么问题?

但是这个错误发生了。

最佳答案

需要发布事件处理程序以便流框架找到它们。您需要将 FormCreate 声明为 published 而不是 public

关于delphi - EReadError - 当我尝试创建 Delphi 单元时属性值无效,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58214849/

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