Login ProductsSalesSupportDownloadsAbout |
Home » Technical Support » Elevate Web Builder Technical Support » Support Forums » Elevate Web Builder General » View Thread |
Messages 1 to 6 of 6 total |
Asking the user for OnCloseQuery response |
Wed, Mar 13 2019 3:05 PM | Permanent Link |
Matthew Jones | I just realised that the normal way to handle OnCloseQuery is to pop up a dialog and ask the user if they want to close. But in EWB, isn't that going to not-block, and thus the call will return before the dialog is all complete? What's the way to make this work?
-- Matthew Jones |
Thu, Mar 14 2019 1:01 AM | Permanent Link |
ooptimum | I do it like this:
var FormCloseFlag: Boolean = False; // actually a form field function TMyform.CloseQueryHandler(Sender: TObject): Boolean; begin if FormCloseFlag then Result := True else begin MessageDlg('Are you sure ... ?', 'Please confirm', mtConfirmation, [mbYes, mbNo], mbNo, CheckClose, True); Result := False; // Don't close yet end; end; procedure TMyform.CheckClose(DlgResult: TModalResult); begin if DlgResult = mrYes then begin FormCloseFlag := True; Close; end; end; |
Thu, Mar 14 2019 4:33 AM | Permanent Link |
Matthew Jones | ooptimum wrote:
> I do it like this: > > var FormCloseFlag: Boolean = False; // actually a form field > > ... A nice solution - unfortunately my application is sort of stateless, so I'd have to remember where the user wanted to go too. What I've done for the moment is just show a red label telling them to save or discard first, and abort the action with an exception that I ignore. Basically I lock them in the form using a flag as you suggest that indicates if there is something to save or not. -- Matthew Jones |
Thu, Mar 14 2019 5:37 AM | Permanent Link |
ooptimum | << What I've done for the moment is just show a red label telling them to save or discard first, and abort the action with an exception that I ignore. Basically I lock them in the form using a flag as you suggest that indicates if there is something to save or not. >>
I think there is a simpler solution without imploying exceptions, if I understand you right. function TMyform.CloseQueryHandler(Sender: TObject): Boolean; begin if WeHaveSomethingToSave then begin // Inform a user here that data should be saved or discarded first Result := False; // don't allow form to close else Result := True; end; |
Thu, Mar 14 2019 6:05 AM | Permanent Link |
Matthew Jones | ooptimum wrote:
> << What I've done for the moment is just show a red label telling them to save or discard first, and abort the action with an exception that I ignore. Basically I lock them in the form using a flag as you suggest that indicates if there is something to save or not. >> > > I think there is a simpler solution without imploying exceptions, if I understand you right. > > function TMyform.CloseQueryHandler(Sender: TObject): Boolean; > begin > if WeHaveSomethingToSave then begin > // Inform a user here that data should be saved or discarded first > Result := False; // don't allow form to close > else > Result := True; > end; That's basically what I'm doing, except that the user has clicked a button so do something else, and the form won't be visible any more if that continues. Therefore I have to use an exception to stop that happening. -- Matthew Jones |
Thu, Mar 14 2019 6:06 AM | Permanent Link |
Matthew Jones | I should say that the form is not modal - hence the issue. I pondered going modal, but I don't think that would look good.
-- Matthew Jones |
This web page was last updated on Tuesday, April 23, 2024 at 08:10 AM | Privacy PolicySite Map © 2024 Elevate Software, Inc. All Rights Reserved Questions or comments ? E-mail us at info@elevatesoft.com |