Thank you, but the problem is with the property
IsMainWindowI can set ACCEPT to TRUE or FALSE for each form, but that only determines if the FORM will close and not the APPLET.
This is a workaround but it is a bit messy:
program FormsTest;
uses KOL;
var
Form1, Form2, Form3: PControl;
procedure FormClose(Dummy: Pointer; Sender: PObj; var Accept: Boolean);
begin
if not PControl(Sender).IsMainWindow then
Accept := True
else
begin
Accept := Applet.ChildCount = 1;
PControl(Sender).Free;
end;
end;
begin
Applet := NewApplet('Forms Test');
Form1 := NewForm(Applet, 'Form1').SetSize(320, 240);
Form1.OnClose := TOnEventAccept(MakeMethod(nil, @FormClose));
Form2 := NewForm(Applet, 'Form2').SetSize(320, 240);
Form2.OnClose := TOnEventAccept(MakeMethod(nil, @FormClose));
Form3 := NewForm(Applet, 'Form3').SetSize(320, 240);
Form3.OnClose := TOnEventAccept(MakeMethod(nil, @FormClose));
Run(Applet);
end.
Is there a more logical way? Or a way to override IsMainWindow?