My application is bad when I add a secondary form.
Why?
This is my code:
Cli.lpr
{ KOL MCK } // Do not remove this line!
{$DEFINE KOL_MCK}
{$ifdef FPC} {$mode delphi} {$endif}
program Cli;
uses
KOL,
Unit1, Unit2;
begin // PROGRAM START HERE -- Please do not remove this comment
{$IFNDEF LAZIDE_MCK} {$I Cli_0.inc} {$ELSE}
Application.Initialize;
Application.CreateForm(TForm1, Form1);
Application.Run;
{$ENDIF}
end.
Unit1.pas
{ KOL MCK } // Do not remove this line!
{$DEFINE KOL_MCK}
{$ifdef FPC} {$mode delphi} {$endif}
unit Unit1;
interface
uses Windows, Messages, KOL {place your units here->}
{$IFDEF LAZIDE_MCK}, Forms, mirror, Classes, Controls, mckCtrls, mckObjs, Graphics;
{$ELSE} ; {$ENDIF}
type
{ TForm1 }
{$I MCKfakeClasses.inc}
{$IFDEF KOLCLASSES} TForm1 = class; PForm1 = TForm1; {$ELSE OBJECTS} PForm1 = ^TForm1; {$ENDIF CLASSES/OBJECTS}
TForm1 = {$IFDEF KOLCLASSES}class{$ELSE}object{$ENDIF}({$IFDEF LAZIDE_MCK}TForm{$ELSE}TObj{$ENDIF})
Button1: TKOLButton;
Button2: TKOLButton;
Form: PControl;
KOLApplet1: TKOLApplet;
KOLForm1: TKOLForm;
KOLProject1: TKOLProject;
MainMenu1: TKOLMainMenu;
procedure N1Menu(Sender: PMenu; Item: Integer);
private
{ private declarations }
public
{ public declarations }
end;
var
Form1 {$IFDEF KOL_MCK} : PForm1 {$ELSE} : TForm1 {$ENDIF} ;
{$IFDEF KOL_MCK}
procedure NewForm1( var Result: PForm1; AParent: PControl );
{$ENDIF}
implementation
uses Unit2;
{$IFDEF KOL_MCK}
{$I unit1_1.inc}
{$ENDIF}
{ TForm1 }
procedure TForm1.N1Menu(Sender: PMenu; Item: Integer);
var
Modal: PForm2;
begin
NewForm2( Modal, Applet );
try
Modal.Form.ShowModal;
finally
Modal.Form.Free;
end;
end;
initialization
{$IFNDEF KOL_MCK} {$I unit1.lrs} {$ENDIF}
end.
Unit2.pas
{ KOL MCK } // Do not remove this line!
{$DEFINE KOL_MCK}
{$ifdef FPC} {$mode delphi} {$endif}
unit Unit2;
interface
uses Windows, Messages, KOL {place your units here->}
{$IFDEF LAZIDE_MCK}, Forms, mirror, Classes, Controls, mckCtrls, mckObjs, Graphics;
{$ELSE} ; {$ENDIF}
type
{ TForm2 }
{$I MCKfakeClasses.inc}
{$IFDEF KOLCLASSES} TForm2 = class; PForm2 = TForm2; {$ELSE OBJECTS} PForm2 = ^TForm2; {$ENDIF CLASSES/OBJECTS}
TForm2 = {$IFDEF KOLCLASSES}class{$ELSE}object{$ENDIF}({$IFDEF LAZIDE_MCK}TForm{$ELSE}TObj{$ENDIF})
Button1: TKOLButton;
Form: PControl;
KOLForm1: TKOLForm;
procedure Button1Click(Sender: PObj);
private
{ private declarations }
public
{ public declarations }
end;
var
Form2 {$IFDEF KOL_MCK} : PForm2 {$ELSE} : TForm2 {$ENDIF} ;
{$IFDEF KOL_MCK}
procedure NewForm2( var Result: PForm2; AParent: PControl );
{$ENDIF}
implementation
{$IFDEF KOL_MCK}
{$I unit2_1.inc}
{$ENDIF}
{ TForm2 }
procedure TForm2.Button1Click(Sender: PObj);
begin
Form.Close;
end;
initialization
{$IFNDEF KOL_MCK} {$I unit2.lrs} {$ENDIF}
end.