Salut Bryan Smith !
Dans un message de Bryan Smith dat‚ du 02 Oct 96 11:40:27 il ‚tait dit:
BS> Can anyone explain why Application.Terminate does not work from within
BS> aloop ? (Delphi 1) I have noticed this problem several times before
BS> indifferent situations.For instance, the following code fragment was
BS> taken from the FormCreatehandler of a MainForm. The intention is to
BS> gather up a number of individualmemos named Memo1, Memo2, etc. and to
BS> assemble them into an array.tcmp is a TComponent, s is a string. for j
BS> := 1 to maxMemo do begin s := 'Memo'+IntToStr(j) ; tcmp :=
BS> Self.FindComponent(s) ; if tcmp = nil then begin MessageDlg('Component
BS> "'+s+'" can not be found.', mtError,[mbOK],0) ; break ; end ;
BS> MemoRay[j] := (tcmp as TMemo) ; end ; if tcmp = nil then
BS> Application.Terminate ;The above code halts as intented if an expected
BS> Memo is missing, but if"break" is replaced by "Application.Terminate",
BS> then the application failsto halt at that point, and the program ends
BS> on an error in the"MemoRay[j] :=" line.
Don't replace the break by application.terminate, but insert it before
the break. Use Exit in place of break. The application.terminate is
just a flag wich will be processed as any other message when your
event handler will be finished (hence the Exit).
Amiti‚s,
{-Francois Piette-}
francois.piette@ping.be
--- SvFido 1.32
---------------
* Origin: OverByte BBS (Embourg-Belgium) 32-4-3651395 V-FAST (2:293/2202)
|