Guest Posted January 13, 2011 Share Posted January 13, 2011 Message from: "Andrew Tierney" I have the following code: procedure TUniForm1.UniFormClose(Sender: TObject; var Action: TCloseAction); begin if (UniMainModule.dsVOR.DataSet.State = dsEdit) or (UniMainModule.dsVOR.DataSet.State = dsInsert) then begin MessageDlg('Save changes before closing?', mtConfirmation, mbYesNo,_Confirm); end; end; But the form disappears before the MessageDlg is display, then a runtime error occurs when I try to access the form which has disappeared. (Again different behavior to the Windows version of the UniGui app). Even if this didn't happen, I gather I need to somehow callback to UniFormClose to set the CloseAction = caNone ??? Any info greatly appreciated. Andrew . Quote Link to comment Share on other sites More sharing options...
Guest Posted January 13, 2011 Author Share Posted January 13, 2011 Message from: "Javi" Hi.... In web mode. A modal window, never block the execution of the event. I think. For example: procedure TUniForm1.UniFormClose(Sender: TObject; var Action: TCloseAction); begin if (UniMainModule.dsVOR.DataSet.State = dsEdit) or (UniMainModule.dsVOR.DataSet.State = dsInsert) then begin MessageDlg('Save changes before closing?', mtConfirmation, mbYesNo,_Confirm); <<== This doesn't stop. end; end; You put a breakpoint on this line =>MessageDlg and you run this application in web mode. I think than you can do other this: procedure TUniForm1.UniFormClose(Sender: TObject; var Action: TCloseAction); begin if (UniMainModule.dsVOR.DataSet.State = dsEdit) or (UniMainModule.dsVOR.DataSet.State = dsInsert) then begin CloseAction = caNone; MessageDlg('Save changes before closing?', mtConfirmation, mbYesNo,_Confirm); end; end; But wait Farshad answer you, if I'm wrong. -- NNTP.hk - (^(oo)^) http://www.nntp.hk/web/ . Quote Link to comment Share on other sites More sharing options...
Guest Posted January 13, 2011 Author Share Posted January 13, 2011 Message from: "Farshad Mohajeri" You may try these steps: -Make BorderStyle = bs Dialog -In BorderIcons biSystemMenu = False (So user can't close the Form from upper right corner) -In OnClose event set CloseAction := caNone unless user is allowed to close the form. "Andrew Tierney" wrote in message news:yS%23qMzssLHA.2084@anaxagvs227... >I have the following code: > > procedure TUniForm1.UniFormClose(Sender: TObject; var Action: > TCloseAction); > begin > if (UniMainModule.dsVOR.DataSet.State = dsEdit) or > (UniMainModule.dsVOR.DataSet.State = dsInsert) then > begin > MessageDlg('Save changes before closing?', mtConfirmation, > mbYesNo,_Confirm); > end; > end; > > But the form disappears before the MessageDlg is display, then a runtime > error occurs when I try to access the form which has disappeared. (Again > different behavior to the Windows version of the UniGui app). > > Even if this didn't happen, I gather I need to somehow callback to > UniFormClose to set the CloseAction = caNone ??? > > Any info greatly appreciated. > > Andrew . Quote Link to comment Share on other sites More sharing options...
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.