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 » Extra libraries, Code snippets, applications etc. » U++ users applications in progress and useful code snippets, including reference examples! » Just one instance of application running (SingleApp)
Just one instance of application running (SingleApp) [message #24603] Mon, 25 January 2010 14:42 Go to previous message
Sc0rch is currently offline  Sc0rch
Messages: 99
Registered: February 2008
Location: Russia, Rubtsovsk
Member

Header:
#ifndef SINGLE_APP_H
#define SINGLE_APP_H

#include <CtrlLib/CtrlLib.h>
using namespace Upp;

class UniqueWindow : public TopWindow
{
public:
	typedef UniqueWindow CLASSNAME;
	UniqueWindow(){}
};

inline bool CreateSingleApp(String name, String unique, bool message = true)
{
#ifdef PLATFORM_WIN32
	name << unique;
	if(::FindWindow(NULL, name))
	{
		if (message)
			Exclamation("Another instance of application already exists!");
		return false;
	}
	Single<UniqueWindow>().SetRect(-1, -1, 1, 1);
	Single<UniqueWindow>().Hide();
	Single<UniqueWindow>().Title(name);
	Single<UniqueWindow>().Open();
#endif
	return true;
}

#endif // SINGLE_APP_H


Using:
GUI_APP_MAIN
{
	if (!CreateSingleApp("SingleApp Test", "##SingleApp##1.0"))
		return;

	MainWindow().Run();
}
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Port giFT (a great but abandoned P2P project) to U++?
Next Topic: array vs. array's items.id sorting/searching
Goto Forum:
  


Current Time: Thu Apr 25 23:48:07 CEST 2024

Total time taken to generate the page: 2.01507 seconds