<?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[Programm in den Tray - und wieder raus!!!]]></title><description><![CDATA[<p>Hi..<br />
Ich hab bis tjetzt folgenden code:</p>
<pre><code class="language-cpp">void IcoToTray (HWND hwnd, BOOL bShow)
{
	NOTIFYICONDATA tsym;
    ZeroMemory (&amp;tsym, sizeof (NOTIFYICONDATA));

	if (bShow)
	{
		tsym.cbSize = sizeof (NOTIFYICONDATA);
		tsym.hWnd   = hwnd;
		tsym.uID    = 1;
		tsym.uFlags = NIF_ICON | NIF_TIP | NIF_MESSAGE;
		tsym.uCallbackMessage = WM_APP;
		tsym.hIcon  = LoadIcon (NULL, IDI_APPLICATION);
		strcpy (tsym.szTip, &quot;Mein Programm...&quot;);
		Shell_NotifyIcon (NIM_ADD, &amp;tsym);
	}

	else
	{
		tsym.cbSize = sizeof (NOTIFYICONDATA);
		tsym.hWnd   = hwnd;
		tsym.uID    = 1;
		tsym.uFlags = 0;
		Shell_NotifyIcon (NIM_DELETE, &amp;tsym);
	}
	return;
}
</code></pre>
<p>Wie mache ich da jetzt das wenn ich auf das icon klicke das der dialog wieder erscheint???</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/154085/programm-in-den-tray-und-wieder-raus</link><generator>RSS for Node</generator><lastBuildDate>Mon, 27 Apr 2026 18:27:56 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/154085.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 24 Jul 2006 10:59:58 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Programm in den Tray - und wieder raus!!! on Mon, 24 Jul 2006 10:59:58 GMT]]></title><description><![CDATA[<p>Hi..<br />
Ich hab bis tjetzt folgenden code:</p>
<pre><code class="language-cpp">void IcoToTray (HWND hwnd, BOOL bShow)
{
	NOTIFYICONDATA tsym;
    ZeroMemory (&amp;tsym, sizeof (NOTIFYICONDATA));

	if (bShow)
	{
		tsym.cbSize = sizeof (NOTIFYICONDATA);
		tsym.hWnd   = hwnd;
		tsym.uID    = 1;
		tsym.uFlags = NIF_ICON | NIF_TIP | NIF_MESSAGE;
		tsym.uCallbackMessage = WM_APP;
		tsym.hIcon  = LoadIcon (NULL, IDI_APPLICATION);
		strcpy (tsym.szTip, &quot;Mein Programm...&quot;);
		Shell_NotifyIcon (NIM_ADD, &amp;tsym);
	}

	else
	{
		tsym.cbSize = sizeof (NOTIFYICONDATA);
		tsym.hWnd   = hwnd;
		tsym.uID    = 1;
		tsym.uFlags = 0;
		Shell_NotifyIcon (NIM_DELETE, &amp;tsym);
	}
	return;
}
</code></pre>
<p>Wie mache ich da jetzt das wenn ich auf das icon klicke das der dialog wieder erscheint???</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1103046</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1103046</guid><dc:creator><![CDATA[Tay]]></dc:creator><pubDate>Mon, 24 Jul 2006 10:59:58 GMT</pubDate></item><item><title><![CDATA[Reply to Programm in den Tray - und wieder raus!!! on Mon, 24 Jul 2006 11:12:10 GMT]]></title><description><![CDATA[<p>Hi,</p>
<p>lol?!, Na du machen auf gleiche Weise, wie du Fenster hast verschwinden lassen... <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f603.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--grinning_face_with_big_eyes"
      title=":D"
      alt="😃"
    /></p>
<p>Du hast doch unter WM_APP (schätze ich mal, steht ja nit direkt in deinem Post) den Klick der Maus registriert und auf Grund dessen das Fenster versteckt...da kannst du es auch wieder anzeigen.</p>
<p>PS: Ich tipp mal ganz spontan, dass der Code weder von dir ist, noch das du ihn verstanden hast oder...das soll nun keineswegs abwertend sein...jedoch nur einHinweis darauf, dass du ihn vllt. erst verstehen solltest...dann wird auch klar warum da:</p>
<pre><code class="language-cpp">tsym.uCallbackMessage = WM_APP;
</code></pre>
<p>steht. <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1103056</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1103056</guid><dc:creator><![CDATA[CodeFinder]]></dc:creator><pubDate>Mon, 24 Jul 2006 11:12:10 GMT</pubDate></item><item><title><![CDATA[Reply to Programm in den Tray - und wieder raus!!! on Mon, 24 Jul 2006 11:15:35 GMT]]></title><description><![CDATA[<p>also die funktion IcoToTray wird durch einen button im dialgo aufgerufen!!!!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1103058</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1103058</guid><dc:creator><![CDATA[tay]]></dc:creator><pubDate>Mon, 24 Jul 2006 11:15:35 GMT</pubDate></item><item><title><![CDATA[Reply to Programm in den Tray - und wieder raus!!! on Mon, 24 Jul 2006 12:05:17 GMT]]></title><description><![CDATA[<p>Schreib einfach n MessageHandler für die Nachricht WM_APP.</p>
<p>PS: Hast du die Nachricht WM_APP mittels RegisterWindowMessage() registriert ?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1103095</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1103095</guid><dc:creator><![CDATA[CodeFinder]]></dc:creator><pubDate>Mon, 24 Jul 2006 12:05:17 GMT</pubDate></item><item><title><![CDATA[Reply to Programm in den Tray - und wieder raus!!! on Mon, 24 Jul 2006 13:03:49 GMT]]></title><description><![CDATA[<p>Da mir jetzt im Kopf nicht einfällt wie das ging, hab ich nochmal den Code-Schnipsel rausgesucht, der mir geholfen hat:</p>
<p><a href="http://www.winapi.net/index.php?inhalt=s16" rel="nofollow">http://www.winapi.net/index.php?inhalt=s16</a></p>
<p>Da gibts fast nen fertiges Prog.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1103147</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1103147</guid><dc:creator><![CDATA[-=Chris=-]]></dc:creator><pubDate>Mon, 24 Jul 2006 13:03:49 GMT</pubDate></item><item><title><![CDATA[Reply to Programm in den Tray - und wieder raus!!! on Fri, 11 Jan 2008 09:09:58 GMT]]></title><description><![CDATA[<p>Hallo @ll,<br />
ich wollt nicht wieder ein neues Thread aufmachen.</p>
<p>Ich habe ein ähnliches Problem, und dank dem Codeschnippsel habe ich folgendes überlegt:<br />
entweder ich finde einfach den Fehler nicht,<br />
oder ich habe die falsche Ausbildung gewählt <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f60b.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--face_savoring_food"
      title=":yum:"
      alt="😋"
    /></p>
<pre><code class="language-cpp">#include &lt;stdio.h&gt;
#define _WIN32_WINNT 0x0600
#include &lt;windows.h&gt;
#include &lt;time.h&gt;
#include &lt;winsock.h&gt;
#include &lt;conio.h&gt;
#include &lt;stdbool.h&gt;
#include &quot;./header/strops.h&quot;
#include &lt;commctrl.h&gt;

#define WM_ICONCLICK (WM_APP+0)

/*1 = Add ToTray|| 0 = DelFromTray*/
bool SysTray_IconOpts( HWND hWnd, bool add );
LRESULT CALLBACK WndProc( HWND, UINT, WPARAM, LPARAM );

/************************** MAIN *******************************/
int main( void )
{
	RegisterWindowMessage( &quot;WM_APP&quot; );
	RegisterWindowMessage( &quot;WM_ICONCLICK&quot; );
	//benötigte variablen
	HWND myCMD, nextWindow;
	char *text;
	int answer;
	MSG msg;

	text = malloc( sizeof( char ) * 1024 );

	//Das Konsolenfenster finden.
	myCMD = (HWND) GetConsoleWindow();

	//Fenster in den Tray eintragen
	if( SysTray_IconOpts( myCMD, 1 ) )
		//Fenster verstecken
		ShowWindow( myCMD, SW_HIDE );
	//
	else
		printf( &quot;Failure&quot; );

	nextWindow = GetNextWindow( myCMD, GW_HWNDNEXT );

	MessageBox( NULL, &quot;blubb&quot;, &quot;hey&quot;, MB_OK );

	while( GetMessage( &amp;msg, NULL, 0, 0 ) )
	{
		TranslateMessage( &amp;msg );
		DispatchMessage( &amp;msg );
	}

	MessageBox( NULL, text, &quot;hey2&quot;, MB_OK );
}

bool SysTray_IconOpts( HWND hWnd, bool add )
{
	int ret;

	ret = 0;

	if( 1 == add )
	{
		/*Nötigkeitsdaten für die Tray Option.								*/
	    NOTIFYICONDATA nid; 

		char *ballonText = &quot;This is NaDiA. Its the 'net send' command for Vista&quot;,
			 *ballonTitle = &quot;NachrichtenDienstApplikation(NaDiA)&quot;;

	    nid.cbSize = sizeof(NOTIFYICONDATA);
		/*Das Fenster, zu dem der Tray-Eintrag gehört.							*/
	    nid.hWnd = hWnd;
		/*Die Tray_ID, damit sie später gelöscht werden kann.						*/
	    nid.uID = 0x0200;
		/*Das icon dess Tray-Eintrages.									*/
		nid.hIcon = LoadImage( NULL, &quot;C:\\NaDiA\\48.ico&quot;, IMAGE_ICON, 48, 48, LR_DEFAULTCOLOR | LR_LOADFROMFILE );

		strcpy( nid.szTip, ballonText );

		nid.uCallbackMessage = WM_ICONCLICK;
		/*Was alles möglich sein soll, momentan  nur der Icon und das Draufklicken.		*/
		nid.uFlags = NIF_ICON | NIF_MESSAGE | NIF_TIP;

	    ret = Shell_NotifyIcon(NIM_ADD, &amp;nid);
	}
	else
	{
		/*Nötigkeitsdaten für die Tray Option.								*/
	    NOTIFYICONDATA    nid;
	    memset(&amp;nid, 0, sizeof(nid));
	    nid.cbSize = sizeof(nid);
		/*Das Fenster, zu dem der Tray-Eintrag gehört.							*/
	    nid.hWnd = hWnd;

		nid.uFlags = 0;

		/*Die Tray_ID, damit sie später gelöscht werden kann.						*/
	    nid.uID = 0x0200;
	    ret = Shell_NotifyIcon(NIM_DELETE, &amp;nid);
	}

	return ret;
}

LRESULT CALLBACK WndProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam )
{
	UINT uID; 
    UINT uMouseMsg; 

	MessageBox( NULL, &quot;ich war hier&quot;, &quot;und du liest es&quot;, MB_OK );

	/*Die Gesendete Message.											*/
    uID = (UINT)wParam;
	/*Die gedrückte Maustaste.											*/
    uMouseMsg = (UINT)lParam;

	if( WM_ICONCLICK == msg )
	{
		if( WM_LBUTTONUP == uMouseMsg )
		{
			MessageBox( NULL, &quot;WM_LBUTTONDOWN&quot;, &quot;if..&quot;, 0 );
		}
		else
			MessageBox( NULL, &quot;Else&quot;, &quot;anders&quot;, 0 );
	}
	else
		MessageBox( NULL, &quot;Else&quot;, &quot;anders2&quot;, 0 );
}
</code></pre>
<p>So, da sehe ich:<br />
Den NIF_TIP | NIF_ICON <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f44d.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--thumbs_up"
      title=":+1:"
      alt="👍"
    /><br />
aber kein NIF_MESSAGE... <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f44e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--thumbs_down"
      title=":-1:"
      alt="👎"
    /></p>
<p>Ich verstehe dass nicht, ich habe ja schon angefangen aus diesem Codeschnippsel was zu übernehmen <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f62e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--face_with_open_mouth"
      title=":open_mouth:"
      alt="😮"
    /></p>
<p>Ich programmiere mit C und MinGW(der Compiler) und dann noch Notepad++(Texteditor)...<br />
Habe Windows Vista und einen passenden PC.</p>
<p>Ich frage mich ehrlich wo ich da den Fehler gemacht habe...<br />
könnt ihr mir bitte helfen`?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1434721</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1434721</guid><dc:creator><![CDATA[lippoliv]]></dc:creator><pubDate>Fri, 11 Jan 2008 09:09:58 GMT</pubDate></item><item><title><![CDATA[Reply to Programm in den Tray - und wieder raus!!! on Fri, 11 Jan 2008 09:20:50 GMT]]></title><description><![CDATA[<p>Kannst du bitte genauer erklären, wo dein Problem liegt? Du hast dort &quot;NIF_ICON | NIF_MESSAGE | NIF_TIP&quot; angegeben, also werden auch alle drei Werte übernommen (btw, das Tray-Icon schickt dir alle Arten von Maus-Nachrichten, da mußt du schon selber die Klicks herausfiltern).</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1434730</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1434730</guid><dc:creator><![CDATA[CStoll]]></dc:creator><pubDate>Fri, 11 Jan 2008 09:20:50 GMT</pubDate></item><item><title><![CDATA[Reply to Programm in den Tray - und wieder raus!!! on Fri, 11 Jan 2008 09:29:50 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">LRESULT CALLBACK WndProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam )
{
    UINT uID;
    UINT uMouseMsg;

    MessageBox( NULL, &quot;ich war hier&quot;, &quot;und du liest es&quot;, MB_OK );
[...]
</code></pre>
<p>sry war nicht präzise genug...</p>
<p>Diese MessageBox wird nicht angezeigt... nie...<br />
Also geht er auch dementsprechend nciht in diese Funktion...</p>
<p>Aber wie ich dass mitbekommen habe, sollte er da rein gehen, wenn er ne Message bekommt oder nciht?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1434736</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1434736</guid><dc:creator><![CDATA[lippoliv]]></dc:creator><pubDate>Fri, 11 Jan 2008 09:29:50 GMT</pubDate></item><item><title><![CDATA[Reply to Programm in den Tray - und wieder raus!!! on Fri, 11 Jan 2008 09:37:08 GMT]]></title><description><![CDATA[<p>Wenn die WndProc genutzt werden soll, mußt du dem System auch sagen, daß sie existiert (RegisterClass()). (aber dazu können dir die WinAPI-Experten sicher mehr erzählen)</p>
<p>PS: Die beiden Nachrichten, die du bei Programmanfang mit RegisterWindowMessage() anlegst, haben herzlich wenig mit WM_APP und WM_ICONCLICK zu tun <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1434742</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1434742</guid><dc:creator><![CDATA[CStoll]]></dc:creator><pubDate>Fri, 11 Jan 2008 09:37:08 GMT</pubDate></item><item><title><![CDATA[Reply to Programm in den Tray - und wieder raus!!! on Fri, 11 Jan 2008 09:46:01 GMT]]></title><description><![CDATA[<p>Ja gut, dann können die raus ja?</p>
<p>RegisterClass hört sich nach klassen an... diese gibt es in C doch nciht oder?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1434753</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1434753</guid><dc:creator><![CDATA[lippoliv]]></dc:creator><pubDate>Fri, 11 Jan 2008 09:46:01 GMT</pubDate></item><item><title><![CDATA[Reply to Programm in den Tray - und wieder raus!!! on Fri, 11 Jan 2008 09:49:49 GMT]]></title><description><![CDATA[<p>Ja, RegisterClass() hört sich nach Klassen an - aber das hat nichts mit den Klassen in C++ zu tun, sondern mit den Fensterklassen der WinAPI.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1434754</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1434754</guid><dc:creator><![CDATA[CStoll]]></dc:creator><pubDate>Fri, 11 Jan 2008 09:49:49 GMT</pubDate></item><item><title><![CDATA[Reply to Programm in den Tray - und wieder raus!!! on Fri, 11 Jan 2008 10:20:44 GMT]]></title><description><![CDATA[<p>Meine main:</p>
<pre><code class="language-cpp">int main( void )
{
	//benötigte variablen
	HWND myCMD, nextWindow;
	char *text;
	int answer;
	MSG msg;

	WNDCLASSEX wndclassex = {0};

	wndclassex.cbSize         = sizeof(WNDCLASSEX);
    wndclassex.style          = CS_HREDRAW | CS_VREDRAW;
    wndclassex.lpfnWndProc    = *WndProc;
    wndclassex.cbClsExtra     = 0;
    wndclassex.cbWndExtra     = 0;
    wndclassex.hInstance      = 0;
    wndclassex.hIcon          = NULL;
    wndclassex.hCursor        = LoadCursor( NULL, IDC_ARROW );
    wndclassex.hbrBackground  = WHITE_BRUSH;
    wndclassex.lpszMenuName   = NULL;
    wndclassex.lpszClassName  = &quot;test&quot;;
    wndclassex.hIconSm        = wndclassex.hIcon;

	RegisterClassEx( &amp;wndclassex );

	text = malloc( sizeof( char ) * 1024 );

	//Das Konsolenfenster finden.
	myCMD = (HWND) GetConsoleWindow();

	//Fenster in den Tray eintragen
	if( SysTray_IconOpts( myCMD, 1 ) )
		//Fenster verstecken
		ShowWindow( myCMD, SW_HIDE );
	//
	else
		printf( &quot;Failure&quot; );

	nextWindow = GetNextWindow( myCMD, GW_HWNDNEXT );

	MessageBox( NULL, &quot;blubb&quot;, &quot;hey&quot;, MB_OK );

	while( GetMessage( &amp;msg, NULL, 0, 0 ) )
	{
		TranslateMessage( &amp;msg );
		DispatchMessage( &amp;msg );
	}

	MessageBox( NULL, text, &quot;hey2&quot;, MB_OK );
}
</code></pre>
<p>Es Funktioniert immer noch nicht,<br />
aber:</p>
<pre><code class="language-cpp">wndclassex.hInstance      = 0;
    wndclassex.hIcon          = NULL;
    wndclassex.hbrBackground  = WHITE_BRUSH;
    wndclassex.lpszMenuName   = NULL;
    wndclassex.lpszClassName  = &quot;test&quot;;
</code></pre>
<p>die habe ich glaube ich entweder geschrottet, oder richtig angepasst...</p>
<p>Ich bin mir auch noch nicht so sicher, wofür dass überhaupt gut ist...<br />
Ich will ja nur die WndProc nutzen können, dass ist also dazu da um dem Programm zu sagen, dass es diese gibt?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1434773</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1434773</guid><dc:creator><![CDATA[lippoliv]]></dc:creator><pubDate>Fri, 11 Jan 2008 10:20:44 GMT</pubDate></item><item><title><![CDATA[Reply to Programm in den Tray - und wieder raus!!! on Mon, 14 Jan 2008 09:00:00 GMT]]></title><description><![CDATA[<p>So jetzt bin ich echt am ende...</p>
<pre><code class="language-cpp">#include &lt;stdio.h&gt;
#define _WIN32_WINNT 0x0600
#include &lt;windows.h&gt;
#include &lt;time.h&gt;
#include &lt;winsock.h&gt;
#include &lt;conio.h&gt;
#include &lt;stdbool.h&gt;
#include &quot;./header/strops.h&quot;
#include &lt;commctrl.h&gt;

#define WM_ICONCLICK (WM_APP+0)

/*1 = Add ToTray|| 0 = DelFromTray*/
bool SysTray_IconOpts( HWND hWnd, bool add );
LRESULT CALLBACK WndProc( HWND, UINT, WPARAM, LPARAM );

/************************** MAIN *******************************/
int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrecInstance, LPSTR lpCmdLine, int nCmdShow )
{
	RegisterWindowMessage( &quot;WM_APP&quot; );
	RegisterWindowMessage( &quot;WM_ICONCLICK&quot; );
	//benötigte variablen
	HWND myCMD, nextWindow;
	char *text;
	int answer;
	MSG msg;

	WNDCLASSEX wndclassex = {0};

	wndclassex.cbSize         = sizeof(WNDCLASSEX);
    wndclassex.style          = CS_HREDRAW | CS_VREDRAW;
    wndclassex.lpfnWndProc    = (WNDPROC)WndProc;
    wndclassex.cbClsExtra     = 0;
    wndclassex.cbWndExtra     = 0;
    wndclassex.hInstance      = hInstance;
    wndclassex.hIcon          = LoadImage( NULL, &quot;C:\\NaDiA\\48.ico&quot;, IMAGE_ICON, 48, 48, LR_DEFAULTCOLOR | LR_LOADFROMFILE );
    wndclassex.hCursor        = LoadCursor( NULL, IDC_ARROW );
    wndclassex.hbrBackground  = (HBRUSH)GetStockObject( WHITE_BRUSH );
    wndclassex.lpszMenuName   = NULL;
    wndclassex.lpszClassName  = &quot;test&quot;;
    wndclassex.hIconSm        = wndclassex.hIcon;

	RegisterClassEx( &amp;wndclassex );
</code></pre>
<p>Ob man noch alle Include Dateien braucht weis ich nicht.<br />
Aber eigentlich sollte -für diesen abschnitt zumindest- die windows.h reichen.</p>
<pre><code>./ccC0baaa.o:tray.c:(.text+0x4ce): undefined reference to `GetStockObject@4'
</code></pre>
<p>Ich habe in meinem schlauen &quot;C Einführung und professionelle Anwendungen&quot; nachgeschaut, und so meine Struktur aufgebessert. Die binden auch nur die windows.h ein...</p>
<p>Wieso nur....</p>
<p>[edit]<br />
&quot;Gdi32.lib&quot; bitte nicht vergessen <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f62e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--face_with_open_mouth"
      title=":open_mouth:"
      alt="😮"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1436207</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1436207</guid><dc:creator><![CDATA[lippoliv]]></dc:creator><pubDate>Mon, 14 Jan 2008 09:00:00 GMT</pubDate></item><item><title><![CDATA[Reply to Programm in den Tray - und wieder raus!!! on Mon, 14 Jan 2008 10:14:51 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">#include &lt;stdio.h&gt;
#define _WIN32_WINNT 0x0600
#include &lt;windows.h&gt;
#include &lt;time.h&gt;
#include &lt;winsock.h&gt;
#include &lt;conio.h&gt;
#include &lt;stdbool.h&gt;
#include &quot;./header/strops.h&quot;
#include &lt;commctrl.h&gt;

#define WM_ICONCLICK (WM_APP+0)

/*1 = Add ToTray|| 0 = DelFromTray*/
bool SysTray_IconOpts( HWND hWnd, bool add );
LRESULT CALLBACK WndProc( HWND, UINT, WPARAM, LPARAM );
void initInstance( int, HINSTANCE );

/************************** MAIN *******************************/
int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrecInstance, LPSTR lpCmdLine, int nCmdShow )
{
	RegisterWindowMessage( &quot;WM_APP&quot; );
	RegisterWindowMessage( &quot;WM_ICONCLICK&quot; );
	//benötigte variablen
	HWND myCMD, nextWindow;
	char *text;
	int answer;
	MSG msg;

	WNDCLASSEX wndclassex;

	wndclassex.cbSize         = sizeof(WNDCLASSEX);
    wndclassex.style          = CS_HREDRAW | CS_VREDRAW;
    wndclassex.lpfnWndProc    = (WNDPROC)WndProc;
    wndclassex.cbClsExtra     = 0;
    wndclassex.cbWndExtra     = 0;
    wndclassex.hInstance      = hInstance;
    wndclassex.hIcon          = LoadImage( NULL, &quot;C:\\NaDiA\\48.ico&quot;, IMAGE_ICON, 48, 48, LR_DEFAULTCOLOR | LR_LOADFROMFILE );
    wndclassex.hCursor        = LoadCursor( NULL, IDC_ARROW );
    wndclassex.hbrBackground  = (HBRUSH)GetStockObject( WHITE_BRUSH );
    wndclassex.lpszMenuName   = NULL;
    wndclassex.lpszClassName  = &quot;test&quot;;
    wndclassex.hIconSm        = wndclassex.hIcon;

	RegisterClassEx( &amp;wndclassex );

	initInstance( nCmdShow, hInstance );

	text = malloc( sizeof( char ) * 1024 );

	//Das Konsolenfenster finden.
	myCMD = (HWND) GetConsoleWindow();

	//Fenster in den Tray eintragen
	if( SysTray_IconOpts( myCMD, 1 ) )
		//Fenster verstecken
		ShowWindow( myCMD, SW_HIDE );
	//
	else
		printf( &quot;Failure&quot; );

	nextWindow = GetNextWindow( myCMD, GW_HWNDNEXT );

	while( GetMessage( &amp;msg, NULL, 0, 0 ) )
	{
		TranslateMessage( &amp;msg );
		DispatchMessage( &amp;msg );

		Sleep( 10 );
	}

	return msg.wParam;
}

bool SysTray_IconOpts( HWND hWnd, bool add )
{
	int ret;

	ret = 0;

	if( 1 == add )
	{
		/*Nötigkeitsdaten für die Tray Option.								*/
	    NOTIFYICONDATA nid; 

		char *ballonText = &quot;This is NaDiA. Its the 'net send' command for Vista&quot;,
			 *ballonTitle = &quot;NachrichtenDienstApplikation(NaDiA)&quot;;

	    nid.cbSize = sizeof(NOTIFYICONDATA);
		/*Das Fenster, zu dem der Tray-Eintrag gehört.							*/
	    nid.hWnd = hWnd;
		/*Die Tray_ID, damit sie später gelöscht werden kann.						*/
	    nid.uID = 1;
		/*Das icon dess Tray-Eintrages.									*/
		nid.hIcon = LoadImage( NULL, &quot;C:\\NaDiA\\48.ico&quot;, IMAGE_ICON, 48, 48, LR_DEFAULTCOLOR | LR_LOADFROMFILE );

		strcpy( nid.szTip, ballonText );

		nid.uCallbackMessage = WM_ICONCLICK;
		/*Was alles möglich sein soll, momentan  nur der Icon und das Draufklicken.		*/
		nid.uFlags = NIF_ICON | NIF_MESSAGE | NIF_TIP;

	    ret = Shell_NotifyIcon(NIM_ADD, &amp;nid);
	}
	else
	{
		/*Nötigkeitsdaten für die Tray Option.								*/
	    NOTIFYICONDATA    nid;
	    memset(&amp;nid, 0, sizeof(nid));
	    nid.cbSize = sizeof(nid);
		/*Das Fenster, zu dem der Tray-Eintrag gehört.							*/
	    nid.hWnd = hWnd;

		nid.uFlags = 0;

		/*Die Tray_ID, damit sie später gelöscht werden kann.						*/
	    nid.uID = 0x0200;
	    ret = Shell_NotifyIcon(NIM_DELETE, &amp;nid);
	}

	return ret;
}

LRESULT CALLBACK WndProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam )
{
	UINT uID; 
    UINT uMouseMsg; 

	/*Die Gesendete Message.											*/
    uID = (UINT)wParam;

	switch( msg )
	{
		case WM_ICONCLICK:
			MessageBox( hWnd, &quot;ICONCLICK&quot;, &quot;Info&quot;, MB_OK );
			switch( lParam )
			{
				case WM_LBUTTONUP:
					MessageBox( hWnd, &quot;Linke Maustaste&quot;, &quot;Info&quot;, MB_OK );
				break;
				default:
					MessageBox( hWnd, &quot;Andere Maustaste&quot;, &quot;Info&quot;, MB_OK );
				break;
			}
		break;
		case WM_DESTROY:
			SysTray_IconOpts( hWnd, 0 );

			PostQuitMessage( 0 );
		break;
	}

	return DefWindowProc( hWnd, msg, wParam, lParam );
}

void initInstance( int Inst, HINSTANCE hInstance )
{
	HWND hWnd;

	hWnd = CreateWindow( &quot;test&quot;, &quot;nocheiner&quot;,
						 WS_OVERLAPPEDWINDOW, CW_USEDEFAULT,
						 0, CW_USEDEFAULT, 0, NULL, NULL,
						 hInstance, NULL );

	UpdateWindow( hWnd );
}
</code></pre>
<p>Noch sehr unkommentiert ich weis <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f61e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--disappointed_face"
      title=":("
      alt="😞"
    /></p>
<p>ABER:<br />
es geht nicht, allso er geht schonmal in diese WndProc rein, aber nicht in mein WM_ICONCLICK... warum?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1436254</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1436254</guid><dc:creator><![CDATA[lippoliv]]></dc:creator><pubDate>Mon, 14 Jan 2008 10:14:51 GMT</pubDate></item><item><title><![CDATA[Reply to Programm in den Tray - und wieder raus!!! on Mon, 14 Jan 2008 13:56:40 GMT]]></title><description><![CDATA[<p>Ich setze hier ein Post nach den anderen, tut mir leid, aber sonst schaut hier ja keiner rein.</p>
<p>Also ich verstehe dass nicht, iach habe mir <a href="http://www.winapi.net/index.php?inhalt=s16" rel="nofollow">http://www.winapi.net/index.php?inhalt=s16</a> zur hilfe genommen, und leider musste ich feststellen dass dass so nicht geht.</p>
<p>Ich habe bemerkt dass das eine cpp Datei ist.<br />
Ich programmiere in C ist es also überhaupt möglich sowas zu machen?</p>
<pre><code class="language-cpp">#define WM_ICONCLICK (WM_APP + 1)
[...]
nid.uCallbackMessage = WM_ICONCLICK;
[...]
LRESULT CALLBACK WndProc( HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam )
{
	MessageBox( NULL, &quot;Hier is was&quot;, &quot;Nachricht-Benachrichtigung&quot;, MB_OK );
	switch( message )
	{
		case WM_ICONCLICK:
			switch( lParam )
			{
				case WM_LBUTTONDOWN:
					SysTray_IconOpts( hWnd, 0 );
				break;
				default:
					SysTray_IconOpts( hWnd, 0 );
				break;
			}
		break;
		case WM_DESTROY:
			SysTray_IconOpts( hWnd, 0 );

			PostQuitMessage( 0 );
		break;
	}

	return DefWindowProc( hWnd, message, wParam, lParam );
}
</code></pre>
<p>Wenn ich jetzt schreibe</p>
<pre><code class="language-cpp">//Das Fenster registrieren, damit uCallbackMessage funktioniert
	WNDCLASSEX wndclassex;

	//größe der Struktur
	wndclassex.cbSize         = sizeof(WNDCLASSEX);
    wndclassex.style          = CS_HREDRAW | CS_VREDRAW;
	//Die Prozedure für dass Fenster(hier: überprüfung der Messages)
    wndclassex.lpfnWndProc    = (WNDPROC)WndProc;
	//eventueller zusätzlicher Speicher, den das Programm benötigt
    wndclassex.cbClsExtra     = 0;
    wndclassex.cbWndExtra     = 0;
	//Handle von der Instanz
    wndclassex.hInstance      = hInstance;
	//Das icon
    wndclassex.hIcon          = LoadImage( NULL, &quot;C:\\NaDiA\\48.ico&quot;, IMAGE_ICON, 48, 48, LR_DEFAULTCOLOR | LR_LOADFROMFILE );
	//Der Cursor(Standard)
    wndclassex.hCursor        = LoadCursor( NULL, IDC_ARROW );
	//Hintergrundfarbe
    wndclassex.hbrBackground  = (HBRUSH)GetStockObject( WHITE_BRUSH );
	//Der Menuename(Keines vorhanden)
    wndclassex.lpszMenuName   = NULL;
	//Name des Fensters(egal, da kein Fenster vorhanden [HIDE])
    wndclassex.lpszClassName  = &quot;tray-class&quot;;
	//Icon in kleinformat
    wndclassex.hIconSm        = wndclassex.hIcon;
</code></pre>
<p>Wird die MessageBox -beim Start dess Programmes- nicht angezeigt.</p>
<pre><code class="language-cpp">//Das Fenster registrieren, damit uCallbackMessage funktioniert
	WNDCLASSEX wndclassex;

	//größe der Struktur
	wndclassex.cbSize         = sizeof(WNDCLASSEX);
    wndclassex.style          = CS_HREDRAW | CS_VREDRAW;
	//Die Prozedure für dass Fenster(hier: überprüfung der Messages)
    wndclassex.lpfnWndProc    = (WNDPROC)WndProc;
	//eventueller zusätzlicher Speicher, den das Programm benötigt
    wndclassex.cbClsExtra     = 0;
    wndclassex.cbWndExtra     = 0;
	//Handle von der Instanz
    wndclassex.hInstance      = hInstance;
	//Das icon
    wndclassex.hIcon          = LoadImage( NULL, &quot;C:\\NaDiA\\48.ico&quot;, IMAGE_ICON, 48, 48, LR_DEFAULTCOLOR | LR_LOADFROMFILE );
	//Der Cursor(Standard)
    wndclassex.hCursor        = LoadCursor( NULL, IDC_ARROW );
	//Hintergrundfarbe
    wndclassex.hbrBackground  = (HBRUSH)GetStockObject( WHITE_BRUSH );
	//Der Menuename(Keines vorhanden)
    wndclassex.lpszMenuName   = NULL;
	//Name des Fensters(egal, da kein Fenster vorhanden [HIDE])
    wndclassex.lpszClassName  = &quot;test&quot;; //&lt;&lt; HIER ist die änderung
	//Icon in kleinformat
    wndclassex.hIconSm        = wndclassex.hIcon;
</code></pre>
<p>So werden beim Start ca.. ka 15 MessageBoxen angezeigt.</p>
<p>Bei beiden Varianten kann ich jedoch x000 mal auf den Icon klicken, leider passiert NIE auch nur eine sache....</p>
<p>Wisst ihr wieso? Ich verzweifel gerade ehrlich...</p>
<p>Ich habe ja schon bei <a href="http://winapi.net" rel="nofollow">winapi.net</a> -wie oben erwähnt- nachgeschaut, und da ist im grunde alles gleich.<br />
Und da soll es angeblich klappen. <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f62e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--face_with_open_mouth"
      title=":open_mouth:"
      alt="😮"
    /> <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f62e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--face_with_open_mouth"
      title=":open_mouth:"
      alt="😮"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1436356</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1436356</guid><dc:creator><![CDATA[lippoliv]]></dc:creator><pubDate>Mon, 14 Jan 2008 13:56:40 GMT</pubDate></item></channel></rss>