UWord::UWord() { ..... WhenClose = THISBACK(Destroy); ..... } void UWord::Destroy() { if(editor.IsModified()) { switch(PromptYesNoCancel("Do you want to save the changes to the document?")) { case 1: Save(); break; case -1: return; } } delete this; }
bool MyPage::Accept() { bool ok=true; if( DataIsChanged() ) { switch(PromptYesNoCancel("Data Changed, do you want to save?")) { case -1: // Cancel; ok=false; break; case 1: // Yes if(!SuccessfullySaveD()) ok=false; } } return ok; }
Lance wrote on Sun, 10 April 2011 04:57 |
I did some test in U++. I open some files (some are the essential libary files), and make some changes and click the little square on the tab. It silently decides to save the possibly unintentional changes and closes the current tab. I am afraid this is too bold; the traditional Windows' way, user consent before action, is more reasonable IMHO.. |
Lance wrote on Sun, 10 April 2011 05:26 |
WhenClose is a TopWindow callback, so I know how to guard it when the main window is to be closed. Now, like TheIDE, many files(slave ctrls) are in TabCtrl pages, what events should I hook to when a tab page is to be closed? |
Lance wrote on Sun, 11 December 2011 18:28 |
In my case, I use TabCtrl to host different pages that are derivated from ParentCtrl |
Lance wrote on Sun, 11 December 2011 23:57 |
For example, I may be editing something in one tab page and occasionally switch to another tab page to consult some other information. Say I am doing an order, in the process I may become interested in a particular inventory item, e.g. its flow and current count, etc, I will double click the item to bring out a new tab page displaying the inventory activities information. It may not hurt that much to save partial edits but it's preferable not to commit until I (the end user) ask to, e.g. I may subsequently decide to cancel changes made in this session, it will be necessary to remember the edit/undo history if partial changes and saved in the editing process. |
bool MyMain::TabCancelClose(Value key) { return !myTabBarCtrlInstance.FindCtrl(key)->Accept(); }