NS Angga Posted August 6, 2013 Posted August 6, 2013 I create function in a unit that i created, like this : function ConfirmMsg(MsgForm : TUniForm; strMsg : string) : Boolean; var fnConfirm : Boolean; begin Beep; MsgForm.MessageDlg(strMsg, mtConfirmation, mbYesNo, procedure(Res: Integer) begin case Res of mrYes : fnConfirm := True; mrNo : fnConfirm := False; end; end ); Result := fnConfirm; end; when that function i call always return value true or mrYes, even though i chose button "no" == other case, i created function in the same unit, like this : function GetResultModalForm : Boolean; var intResult : integer; //frmTest : TfrmTest; begin result := Null; //frmTest := TfrmTest.Create(UniApplication); --> i made that syntac be comment, cause always return error if frmTest.ShowModal( procedure(AResult:Integer) begin if AResult = 1 then intResult:= AResult; end ); if intResult= 1 then Result = true else Result := False; end; two function above always return same value, why? somebody can explain and correct my syntac Quote
Oliver Morsch Posted August 6, 2013 Posted August 6, 2013 MessageDlg, ShowModal, ShowMessage don't "stop" the code execution in UniGui/WebMode, so you do: (1) You start a Modal Dialog and (2) give a (the initial !) result back. (3) After you click on OK/Cancel/Yes/No/... (4) the anonymous procedure (callback procedure) is called => (2) is before (3) and (4) so it can't contain the future result !!! Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.