Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » Community » Newbie corner » Ctrl::Quit() and system shutdown
Ctrl::Quit() and system shutdown [message #35558] Wed, 29 February 2012 11:06 Go to next message
jjacksonRIAB is currently offline  jjacksonRIAB
Messages: 219
Registered: June 2011
Experienced Member
How do I override a system shutdown to prompt a user, for example, to save their files?

Quit() does not seem to be called when I do a system shutdown, log off, or reboot on either Windows or Linux.

Just using modified example code:

#include <CtrlLib/CtrlLib.h>
 
using namespace Upp;
 
#define IMAGECLASS Tray
#define IMAGEFILE  <TrayIcon/tray.iml>
#include <Draw/iml.h>
 
struct App : TrayIcon {
    virtual void LeftDouble() {
        Icon(Tray::Icon1());
        PromptOK("TrayIcon launched this prompt!");
        Icon(Tray::Icon());
    }
    
    virtual void Quit() {
        PromptOK("Quitting...");
	Break();
    }
    
    virtual void LeftDown() {
        Info("TrayIcon", "You have clicked the TrayIcon!\n""TrayIcon is U++ reference example.");
    }
 
    virtual void Menu(Bar& bar) {
        bar.Add("Info..", THISBACK(LeftDouble));
        bar.Separator();
        bar.Add("Exit", THISBACK(Quit));
    }
 
    typedef App CLASSNAME;
 
    App() {
        Icon(Tray::Icon());
        Tip("This is U++ TrayIcon");
    }
};
 
GUI_APP_MAIN
{
    App().Run();
}


If I shutdown, the PromptOK window never shows, but it does show when I select Exit...

[Updated on: Wed, 29 February 2012 12:10]

Report message to a moderator

Re: Ctrl::Quit() and system shutdown [message #35565 is a reply to message #35558] Wed, 29 February 2012 16:32 Go to previous messageGo to next message
BioBytes is currently offline  BioBytes
Messages: 307
Registered: October 2008
Location: France
Senior Member
Hi,

EyeCare the sample of TrayIcon application is derived from TopWindow. So did you this in your code ?

virtual void Close() {
        PromptOK("Quitting...");
	TopWindow::Close();
        //Break();
    }



Regards
Biobytes
Re: Ctrl::Quit() and system shutdown [message #35566 is a reply to message #35565] Wed, 29 February 2012 17:11 Go to previous messageGo to next message
jjacksonRIAB is currently offline  jjacksonRIAB
Messages: 219
Registered: June 2011
Experienced Member
The code I posted is just another example, slightly modified:

http://www.ultimatepp.org/reference$TrayIcon$en-us.html

Maybe the difference is that only TopWindow-derived controls can receive WM_QUERYENDSESSION and TrayIcon cannot?

I cannot call TopWindow::Close because TrayIcon is not TopWindow-derived, and I cannot make it TopWindow-derived using multiple inheritance either.

[Updated on: Wed, 29 February 2012 17:13]

Report message to a moderator

Re: Ctrl::Quit() and system shutdown [message #35567 is a reply to message #35565] Wed, 29 February 2012 17:38 Go to previous message
jjacksonRIAB is currently offline  jjacksonRIAB
Messages: 219
Registered: June 2011
Experienced Member
Ok I created a quick TopWindow-derived app and it does interrupt shutdown. TrayIcon does not receive that event.

I will embed the TrayIcon in a TopWindow control and that should take care of the problem. Thanks!
Previous Topic: EditDouble background color
Next Topic: Using TheIDE/U++ and Visual Studio 2008/2010 IDE as a team in a project
Goto Forum:
  


Current Time: Thu Mar 28 15:27:52 CET 2024

Total time taken to generate the page: 0.01229 seconds