Jump to content

Recommended Posts

Posted

Hi

 

I have a form including a dbnavigator for editing product. When the user closes the form the OnClose events is fired

with the following code. There's a check if the database is in edit or insert mode and if...then fire the message

for saving or canceling the changes.

 

procedure TFormProduct.UniFormClose(Sender: TObject; var Action: TCloseAction);
begin
 if dmMain.Product.State in [dsEdit,dsInsert] then begin
    MessageDlg('Information has been changed but not saved' + '<br/><br/>' + 'Would you like to save the changes (Y/N) ?', mtConfirmation, mbYesNo, QuestionSaveYesNo);
 end;
end;

 

This uses the following Callback code :

 

procedure TFormProduct.QuestionSaveYesNo(Res: Integer);
begin
 case Res of
   mrYes : dmMain.Product.Post;
   mrNo  : dmMain.Product.CancelUpdates;
 end;
end;

 

This should do the trick (normally in vlc it does) but for some reason it doesn't cancel the changes

and the changes are always saved.

 

A other behavior is that the form is already close and only the question is on the screen, normally

both have to be on screen...maybe it's a behavior of EXT JS ?

 

How to modify it so that the form is still on screen including the message (is Onclose the wrong event?)

and the changes are canceld.

 

I still use 0.89 because of the uniEdit desing height issue...which i don'nt know if it's already solved?

 

Regards Peter

Posted

A other behavior is that the form is already close and only the question is on the screen, normally

both have to be on screen...maybe it's a behavior of EXT JS ?

 

Set Action := caNone before (when) you call MessageDlg. In "TFormProduct.QuestionSaveYesNo" you must call Close again (or do nothing in the last case if you ask "YES/NO/CANCEL")

Posted

Hi Oliver,

 

I don't understand where/how to set the ''Set Action :=caNone'' option, can you explain?

 

Regards Peter

Posted

I don't understand where/how to set the ''Set Action :=caNone'' option, can you explain?

 

procedure TFormProduct.UniFormClose(Sender: TObject; var Action: TCloseAction);

Do you see the (var) "action"? ;)

Posted

Hi Oliver

 

Yes i see it :rolleyes: but maybe i'm total stare me blinded but

don't see what to change into caNone ...maybe it's time for weekend ;)

Posted
procedure TFormProduct.UniFormClose(Sender: TObject; var Action: TCloseAction);
begin
  if dmMain.Product.State in [dsEdit,dsInsert] then begin
     Action := caNone;
     MessageDlg('Would you like to save the changes (Y/N/C) ?', mtConfirmation, mbYesNoCancel, QuestionSaveYesNo);
  end;
end;

procedure TFormProduct.QuestionSaveYesNo(Res: Integer);
begin
  case Res of
    mrYes : dmMain.Product.Post;
    mrNo : dmMain.Product.CancelUpdates;
  else 
    EXIT;
  end;
  Close;
end;

 

Try this code, but it is not tested...

Posted

Oliver

 

Many...many thanks for you help... :) this works and just what i needed.

Welll..i should say...if you're around...be drink a beer together

 

Thanks again

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...