Ask to save before close

[Top]  [Chapter]  [Previous]  [Next]

In the function CloseFile_Click we already let TextDynamic ask the user if the file should be saved or not. This is done by wpdllInt1.Memo.TextCommand(3,0,0) - if result is not 0 the user has either saved the file or has chosen not to save.

 

We can now add an event handler to OnClosing which utilizes the boolean AbortClose we have created before.

 

private void WinForm_Closing(object sender, System.ComponentModel.CancelEventArgs e)

{

 AbortClose = false;

 for(int i=WindowMenu.MenuItems.Count-1;!AbortClose&&(i>=0);i--)

 {

   TagMenuItem_Click(WindowMenu.MenuItems[i],null);

   CloseFile_Click(null,null);

 }

 if(AbortClose)e.Cancel = true;

}

 

Now this message will be triggered for each file:

 

 

 


[asktosavebeforeclose.htm]    Copyright © 2007 by WPCubed GmbH