I don't think your teacher will be satisfied if you just move everything (including the form) to a new unit... you could as well rename the unit. hehehe.
I believe what your teacher meant is that your eventsobj class should be in another unit, and you should instantiate it in your main form. You would have something like this:
YourNewUnit.pas:
unit YourNewForm;
...
type
TYourClass = class(...)
...
MainForm.pas:
unit MainForm;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, YourNewUnit;
...
procedure TForm1.FormCreate(Sender: TObject);
begin
with TYourClass.Create(Self) do begin
Parent := Self; //If needed...
//Other initialization stuff
end;
end;
You could also create a private field on the form to hold the reference to your TYourClass
instance if you need to call it later on the code. This would look like this:
unit MainForm;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, YourNewUnit;
type
TForm1 = class(TForm)
private
FYourClass: TYourClass;
...
procedure TForm1.FormCreate(Sender: TObject);
begin
FYourClass := TYourClass.Create(Self);
with FYourClass do begin
Parent := Self; //If needed...
//Other initialization stuff
end;
end;