Конференция "KOL" » End applet when all forms closed
 
  • Jon © (09.09.10 05:08) [0]
    A KOL application always ends when the first child belonging to Applet closes.

    Is there a way to override this?

    I want the Applet to end only when ALL forms are closed.

    program FormsTest;

    uses KOL;

    begin
     Applet := NewApplet('Forms Test');
     NewForm(Applet, 'Form1').SetSize(320, 240); // Closing this ends the applet
     NewForm(Applet, 'Form2').SetSize(320, 240);
     NewForm(Applet, 'Form3').SetSize(320, 240);
     Run(Applet);
    end.

  • RusSun © (09.09.10 13:04) [1]
    Read about
    Accept := FALSE;
  • Jon © (09.09.10 14:46) [2]
    Thank you, but the problem is with the property IsMainWindow

    I 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?
  • RusSun © (09.09.10 15:03) [3]
    May be the older generation knows the answer :)
  • Vladimir Kladov © (09.09.10 17:28) [4]
    Create first a form which is invisible. Then create 3 others. In Applet.OnMessage write a code which is waiting closing these 3 forms, and then closes the first invisible too.
  • Jon © (09.09.10 21:42) [5]
    But I thought that Applet was essentially an invisible empty form. Is there a way to do so using less resources?
 
Конференция "KOL" » End applet when all forms closed
Есть новые Нет новых   [120350   +22][b:0][p:0.001]