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)
Re: Just one instance of application running (SingleApp) [message #24634 is a reply to message #24627] Tue, 26 January 2010 05:41 Go to previous messageGo to previous message
Sc0rch is currently offline  Sc0rch
Messages: 99
Registered: February 2008
Location: Russia, Rubtsovsk
Member

You said:
koldo wrote on Tue, 26 January 2010 03:52


Hello Sc0rch

GetWindowIdFromCaption(name, true) tries to find a window with title == name.

GetWindowIdFromCaption(name, false) will get the window handle of the window with a title that just contains name.

If it does not work could you give me more details ?.

Best regards
Koldo



I've tested both variants, works well for direct use, like:
TopWindow wnd;
wnd.Title("Test");
wnd.Open();

DUMP(GetWindowIdFromCaption("Test"));


But, not working in this code:
#include <CtrlLib/CtrlLib.h>
#include <SysInfo/SysInfo.h>
using namespace Upp;

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

inline bool CreateSingleApp(const String& unique, const String& message)
{
	if (GetWindowIdFromCaption(unique, false) >= 0)
	{
		if (!message.IsEmpty())
			Exclamation(message);
		return false;
	}

	Single<UniqueWindow>().Title(unique).SetRect(-1, -1, 1, 1);
	Single<UniqueWindow>().Hide();
	Single<UniqueWindow>().Open();
	return true;
}

GUI_APP_MAIN
{
	if (!CreateSingleApp("SingleApp Test##SingleApp##1.0", "Another instance of application "
		"already exists!"))
	{
		return;
	}

	TopWindow wnd;
	wnd.SetRect(Size(200, 100));
	wnd.Run();
}


Test, and say, please, maybe it not works only for me.
 
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: Fri Jul 18 05:46:05 CEST 2025

Total time taken to generate the page: 0.00487 seconds