I'm pretty new to Delphi, and I'm not very clear about how classes work yet in Delphi.
Here is my code:
I want to encapsulate SSA_Database and make it private. It is published by default (since this is a form), and if I leave SSA_Database as published or public, it works fine. When I make it private, however (WITHOUT the initialization section) I get the following RUNTIME error:
Exception EClassNotFound in module Project1.exe at <address>. Class TACRDatabase not found.
After some searching, I found some suggestions that I need to add the initialization section with the RegisterClass(TACRDatabase) call.
This results in the following RUNTIME error:
Exception EAccessViolation in module Project1.exe at <address>.
Access Violation at address <address> in module 'Project1.exe'. Read of address <address near 0>
I really don't know what the RegisterClass call accomplishes or why I need it, but I'm apparently doing it wrong.
Thanks for any help!
Here is my code:
Code:
unit DatabaseForm;
interface
uses
SysUtils, Forms, Dialogs, Classes, ACRMain, Db, Utility;
type
TDBForm = class(TForm)
private
{ Private declarations }
SSA_Database: TACRDatabase;
function CreateDatabase(): Integer;
end;
var
DBForm: TDBForm;
implementation
{$R *.DFM}
function TDBForm.CreateDatabase(): Integer;
Begin
SSA_Database.CreateDatabase();
CreateDatabase := 1;
end;
initialization
RegisterClass(TACRDatabase);
end.
I want to encapsulate SSA_Database and make it private. It is published by default (since this is a form), and if I leave SSA_Database as published or public, it works fine. When I make it private, however (WITHOUT the initialization section) I get the following RUNTIME error:
Exception EClassNotFound in module Project1.exe at <address>. Class TACRDatabase not found.
After some searching, I found some suggestions that I need to add the initialization section with the RegisterClass(TACRDatabase) call.
This results in the following RUNTIME error:
Exception EAccessViolation in module Project1.exe at <address>.
Access Violation at address <address> in module 'Project1.exe'. Read of address <address near 0>
I really don't know what the RegisterClass call accomplishes or why I need it, but I'm apparently doing it wrong.
Thanks for any help!