<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Mehrfaches starten verhindern -&amp;gt; TrayIcon1-&amp;gt;Restore()]]></title><description><![CDATA[<p>Hi,</p>
<p>ich habe im projekt quellcodes folgendes stehen:</p>
<pre><code class="language-cpp">WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
{
        Application-&gt;Title = &quot;&quot;;
        HWND hPrevApp = ::FindWindow(NULL, &quot;Mein Title&quot;);

        if(hPrevApp)
        {
           PostMessage(hPrevApp, WM_SYSCOMMAND, SC_RESTORE, 0);
           return 0;
        }
        // else: other instance not found, restore the title and continue
        else
           Application-&gt;Title = &quot;Mein Title&quot;;

        try
        {
                 Application-&gt;Initialize();
                 Application-&gt;Title = &quot;Mein Title&quot;;
                 Application-&gt;CreateForm(__classid(TForm1), &amp;Form1);
                 Application-&gt;Run();
        }
        catch (Exception &amp;exception)
        {
                 Application-&gt;ShowException(&amp;exception);
        }
        return 0;
}
</code></pre>
<p>Meine Anwendung nutzt das Tray Icon und nun möchte gerne, sofern die Anwendung schon geöffnet ist, einfach TrayIcon1-&gt;Restore() aufrufen, da mein jetziger code dies nicht macht.</p>
<p>Oder hat jemand ne andere Idee?</p>
<p>Kevin</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/81929/mehrfaches-starten-verhindern-gt-trayicon1-gt-restore</link><generator>RSS for Node</generator><lastBuildDate>Wed, 01 Jul 2026 06:55:50 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/81929.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 05 Aug 2004 16:41:47 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Mehrfaches starten verhindern -&amp;gt; TrayIcon1-&amp;gt;Restore() on Thu, 05 Aug 2004 16:41:47 GMT]]></title><description><![CDATA[<p>Hi,</p>
<p>ich habe im projekt quellcodes folgendes stehen:</p>
<pre><code class="language-cpp">WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
{
        Application-&gt;Title = &quot;&quot;;
        HWND hPrevApp = ::FindWindow(NULL, &quot;Mein Title&quot;);

        if(hPrevApp)
        {
           PostMessage(hPrevApp, WM_SYSCOMMAND, SC_RESTORE, 0);
           return 0;
        }
        // else: other instance not found, restore the title and continue
        else
           Application-&gt;Title = &quot;Mein Title&quot;;

        try
        {
                 Application-&gt;Initialize();
                 Application-&gt;Title = &quot;Mein Title&quot;;
                 Application-&gt;CreateForm(__classid(TForm1), &amp;Form1);
                 Application-&gt;Run();
        }
        catch (Exception &amp;exception)
        {
                 Application-&gt;ShowException(&amp;exception);
        }
        return 0;
}
</code></pre>
<p>Meine Anwendung nutzt das Tray Icon und nun möchte gerne, sofern die Anwendung schon geöffnet ist, einfach TrayIcon1-&gt;Restore() aufrufen, da mein jetziger code dies nicht macht.</p>
<p>Oder hat jemand ne andere Idee?</p>
<p>Kevin</p>
]]></description><link>https://www.c-plusplus.net/forum/post/576166</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/576166</guid><dc:creator><![CDATA[Kevin Koel]]></dc:creator><pubDate>Thu, 05 Aug 2004 16:41:47 GMT</pubDate></item><item><title><![CDATA[Reply to Mehrfaches starten verhindern -&amp;gt; TrayIcon1-&amp;gt;Restore() on Thu, 05 Aug 2004 18:35:08 GMT]]></title><description><![CDATA[<p>Hi,<br />
möglich wäre das z.B. in dem du eine benutzerdefinierte WindowsMessage sendest und abfängst. Wenn die Message ankommt dann einfach TrayIcon1-&gt;Restore(); aufrufen....</p>
<p>MfG</p>
<p>Alexander Sulfrian</p>
<p>PS: Zu Messages findet sich auch in den FAQ was...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/576237</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/576237</guid><dc:creator><![CDATA[Alexander Sulfrian]]></dc:creator><pubDate>Thu, 05 Aug 2004 18:35:08 GMT</pubDate></item><item><title><![CDATA[Reply to Mehrfaches starten verhindern -&amp;gt; TrayIcon1-&amp;gt;Restore() on Fri, 06 Aug 2004 06:33:49 GMT]]></title><description><![CDATA[<p>Hm, also bei mir funktioniert das, unter Verwendung von TApplicationEvents, auch ohne benutzerdefinierte Nachricht...</p>
<pre><code class="language-cpp">//aus der Projekt.cpp
WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
{
	HANDLE hInstanceMutex = ::CreateMutex(NULL, TRUE, &quot;TESTTI.MUTEX&quot;);
	if (GetLastError() == ERROR_ALREADY_EXISTS)
	{
		if (hInstanceMutex)
			CloseHandle(hInstanceMutex);
		Application-&gt;Title = &quot;&quot;;
		HWND hPrevApp = ::FindWindow(NULL, &quot;TESTTI&quot;);
		if (hPrevApp)
		{
			PostMessage(hPrevApp, WM_SYSCOMMAND, SC_RESTORE, 0); // Falls minimiert
			SetForegroundWindow(hPrevApp); // kein schöner Stil, aber bringt das Fenster in den Vordergrund...
		}
		return 0;
	}
	try
	{
		Application-&gt;Initialize();
		Application-&gt;Title = &quot;TESTTI&quot;;
		Application-&gt;CreateForm(__classid(TForm1), &amp;Form1);
		Application-&gt;Run();
	}
	catch (Exception &amp;exception)
	{
		Application-&gt;ShowException(&amp;exception);
	}
	catch (...)
	{
		try
		{
			throw Exception(&quot;&quot;);
		}
		catch (Exception &amp;exception)
		{
			Application-&gt;ShowException(&amp;exception);
		}
	}
	ReleaseMutex(hInstanceMutex);
	CloseHandle(hInstanceMutex);
	return 0;
}
//---------------------------------------------------------------------------

// die beiden ApplicationEvents:
void __fastcall TForm1::ApplicationEvents1Minimize(TObject *Sender)
{
	ShowWindow(Application-&gt;Handle, SW_HIDE);
	TrayIcon1-&gt;Visible = true;
}
//---------------------------------------------------------------------------

void __fastcall TForm1::ApplicationEvents1Restore(TObject *Sender)
{
	TrayIcon1-&gt;Visible = false;
	ShowWindow(Application-&gt;Handle, SW_SHOW);
}  
//---------------------------------------------------------------------------
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/576459</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/576459</guid><dc:creator><![CDATA[[[global:guest]]]]></dc:creator><pubDate>Fri, 06 Aug 2004 06:33:49 GMT</pubDate></item></channel></rss>