<?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[Dialog schließt ganzes Programm]]></title><description><![CDATA[<p>Hallo,</p>
<p>ich versuche nun meine ersten Schritte in WinAPI für WindowsCE.<br />
Nun bin ich dabei ein kleines Programm zu schreiben, welches einfach 3 Buttons enthält und bei Klick auf einen dieser Button einen neuen Dialog öffnet.<br />
Das klappt auch soweit, nur wenn ich diesen neuen Dialog oben rechts auf dem X schliesse, wird das ganze Programm beendet.<br />
Ich kann den Fehler einfach nicht finden, vielleicht seht ihr ihn ja.</p>
<p>So erzeuge ich den Dialog</p>
<pre><code class="language-cpp">g_hwndScann = CreateDialog( g_hInst, MAKEINTRESOURCE(IDD_SCAN), hWnd, (DLGPROC)ScanProc );
</code></pre>
<p>Und hier die Behandlung der Nachrichten:</p>
<pre><code class="language-cpp">LRESULT CALLBACK ScanProc( HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam )
{
	switch (message)
	{
		case WM_INITDIALOG:
			return TRUE; 

		case WM_COMMAND:
			switch( LOWORD(wParam) )
			{
				case IDOK:

					EndDialog( hDlg, LOWORD(wParam) );
					return TRUE;

				case IDCLOSE:
					EndDialog( hDlg, LOWORD(wParam) );
					return TRUE;

				default:
					break;
			}

			break;
	}
    return FALSE;
}
</code></pre>
<p>Ich kann da keine Fehler finden....</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/146109/dialog-schließt-ganzes-programm</link><generator>RSS for Node</generator><lastBuildDate>Thu, 16 Jul 2026 14:11:02 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/146109.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 04 May 2006 10:44:40 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Dialog schließt ganzes Programm on Thu, 04 May 2006 10:44:40 GMT]]></title><description><![CDATA[<p>Hallo,</p>
<p>ich versuche nun meine ersten Schritte in WinAPI für WindowsCE.<br />
Nun bin ich dabei ein kleines Programm zu schreiben, welches einfach 3 Buttons enthält und bei Klick auf einen dieser Button einen neuen Dialog öffnet.<br />
Das klappt auch soweit, nur wenn ich diesen neuen Dialog oben rechts auf dem X schliesse, wird das ganze Programm beendet.<br />
Ich kann den Fehler einfach nicht finden, vielleicht seht ihr ihn ja.</p>
<p>So erzeuge ich den Dialog</p>
<pre><code class="language-cpp">g_hwndScann = CreateDialog( g_hInst, MAKEINTRESOURCE(IDD_SCAN), hWnd, (DLGPROC)ScanProc );
</code></pre>
<p>Und hier die Behandlung der Nachrichten:</p>
<pre><code class="language-cpp">LRESULT CALLBACK ScanProc( HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam )
{
	switch (message)
	{
		case WM_INITDIALOG:
			return TRUE; 

		case WM_COMMAND:
			switch( LOWORD(wParam) )
			{
				case IDOK:

					EndDialog( hDlg, LOWORD(wParam) );
					return TRUE;

				case IDCLOSE:
					EndDialog( hDlg, LOWORD(wParam) );
					return TRUE;

				default:
					break;
			}

			break;
	}
    return FALSE;
}
</code></pre>
<p>Ich kann da keine Fehler finden....</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1050781</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1050781</guid><dc:creator><![CDATA[Klaus23]]></dc:creator><pubDate>Thu, 04 May 2006 10:44:40 GMT</pubDate></item><item><title><![CDATA[Reply to Dialog schließt ganzes Programm on Thu, 04 May 2006 10:56:05 GMT]]></title><description><![CDATA[<p>So kann man hier auch nichts sehen.<br />
Das Problem sehe ich eher in der nachrichtenschleife. Denn das Beenden eines fensters beendet ja nicht die Nachrichtenschleife, außer es wird ein PostQuitMessage durchgeführt!</p>
<p>Wie sieht denn die Nachrichtenschleife aus, die Du verwendest?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1050789</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1050789</guid><dc:creator><![CDATA[Martin Richter]]></dc:creator><pubDate>Thu, 04 May 2006 10:56:05 GMT</pubDate></item><item><title><![CDATA[Reply to Dialog schließt ganzes Programm on Thu, 04 May 2006 11:51:57 GMT]]></title><description><![CDATA[<p>Die Nachrichtenschleife in der WinMain sieht so aus:</p>
<pre><code class="language-cpp">while (GetMessage(&amp;msg, NULL, 0, 0)) 
	{
		TranslateMessage(&amp;msg);
		DispatchMessage(&amp;msg);
	}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1050833</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1050833</guid><dc:creator><![CDATA[Klaus23]]></dc:creator><pubDate>Thu, 04 May 2006 11:51:57 GMT</pubDate></item><item><title><![CDATA[Reply to Dialog schließt ganzes Programm on Thu, 04 May 2006 12:02:50 GMT]]></title><description><![CDATA[<p>Dann muss irgendwo in Deinem Programm ein PostQuitMessage vorkommen!<br />
Ohne versenden dieser Nachricht wird die Nachrichtenschleife nicht verlassen!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1050838</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1050838</guid><dc:creator><![CDATA[Martin Richter]]></dc:creator><pubDate>Thu, 04 May 2006 12:02:50 GMT</pubDate></item><item><title><![CDATA[Reply to Dialog schließt ganzes Programm on Thu, 04 May 2006 13:12:57 GMT]]></title><description><![CDATA[<p>Setz mach noch WM_DESTROY mit zu. Und dann ShowWindow(). Also so:</p>
<pre><code class="language-cpp">case WM_DESTROY:
 ShowWindow (hDlg, SW_HIDE);
break; //oder return 0;
</code></pre>
<p>Mfg Ominion</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1050882</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1050882</guid><dc:creator><![CDATA[Ominion]]></dc:creator><pubDate>Thu, 04 May 2006 13:12:57 GMT</pubDate></item><item><title><![CDATA[Reply to Dialog schließt ganzes Programm on Thu, 04 May 2006 13:49:41 GMT]]></title><description><![CDATA[<p><a class="plugin-mentions-user plugin-mentions-a" href="https://www.c-plusplus.net/forum/uid/11526">@Ominion</a>: Hat leider keinen Erfolg gebracht.<br />
<a class="plugin-mentions-user plugin-mentions-a" href="https://www.c-plusplus.net/forum/uid/35992">@Martin</a> Richter: Ja klar hab ich ein PostQuitMessage, und zwar beim Destroy des hauptfensters.</p>
<p>Ich poste jetzt mal meinen kompletten Code hier, ich hoffe er sit nicht zu groß:</p>
<pre><code class="language-cpp">int WINAPI WinMain(	HINSTANCE hInstance,
					HINSTANCE hPrevInstance,
					LPTSTR    lpCmdLine,
					int       nCmdShow)
{
	MSG msg;

	g_hInst = hInstance;

	if ( !InitInstance () ) 
	{
		return -1;
	}

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

	return msg.wParam;
}

/*
 *	InitInstance
 *
 *	Erzeugt das Hauptfenster
 */
BOOL InitInstance()
{
	WNDCLASS	wc;

	TCHAR	szTitle[MAX_LOADSTRING];			// Titelzeile
	TCHAR	szWindowClass[MAX_LOADSTRING];		// Klassenname

	/* fenstertitel und Aplicationsnamen aus der Tabelle laden */
	LoadString( g_hInst, IDC_COMBINATION, szWindowClass, MAX_LOADSTRING );
	LoadString( g_hInst, IDS_APP_TITLE, szTitle, MAX_LOADSTRING );

	/* Wenn es schon einmal im Hintergrund läuft,  nach vorne holen */
	hWindow = FindWindow( szWindowClass, szTitle );	

	if ( hWindow ) 
	{
		SetForegroundWindow ( hWindow );    
		return 0;
	} 

	/* Fenster registrieren */
	(void)memset ( &amp;wc, 0, sizeof ( WNDCLASS ) );

    wc.style			= CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS;
    wc.lpfnWndProc		= WndProc;
    wc.hInstance		= g_hInst;
    wc.hbrBackground	= (HBRUSH) GetStockObject(WHITE_BRUSH);
    wc.lpszMenuName		= 0;
    wc.lpszClassName	= szWindowClass;

	if ( ! RegisterClass(&amp;wc) )
	{
		MessageBox ( NULL, TEXT (&quot;RegisterClassEx failed&quot;), TEXT (&quot;Fatal Error&quot; ), 64 );
		return false;
	}

	/* Fenster erstellen */
	hWindow = CreateWindow(   szWindowClass, 
						   szTitle, 
						   WS_VISIBLE, 
						   CW_USEDEFAULT, CW_USEDEFAULT, 
						   CW_USEDEFAULT, CW_USEDEFAULT, 
						   NULL, 
						   NULL, 
						   g_hInst, 
						   NULL);

	if (!hWindow)
	{	
		return FALSE;
	}

	/* Und anzeigen */
	ShowWindow(hWindow, SW_SHOW );
	UpdateWindow(hWindow);

	return TRUE;
}

/*
 *	WndProc
 *
 *	Empfängt die Nachrichten aus dem Hauptfenster
 */
LRESULT CALLBACK WndProc( HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam )
{
	int			wmId, wmEvent;
	RECT		rect;
	int x		= 0;
	int y		= 0;
	int cx		= 0;
	int cy		= 0;

	char	buffer	[ 256 +1 ];
	TCHAR	wbuffer [ 256 + 1];

	SHINITDLGINFO shidi;

	GetWindowRect ( hWnd, &amp;rect );
	x = rect.left;
	y = rect.top;
	cx = rect.right - rect.left;
	cy = rect.bottom - rect.top;

	switch ( message ) 
	{
		case WM_COMMAND:	
			wmId    = LOWORD(wParam); 
			wmEvent = HIWORD(wParam);

			/* Menüaufrufe */
			switch (wmId)
			{	
				case IDD_\1:
					DialogBox(g_hInst, (LPCTSTR)IDD_ABOUTBOX, hWnd, (DLGPROC)AboutProc);
				    break;

				case IDD_SEND:
					MessageBox ( hWnd, TEXT(&quot;Datei senden&quot;), TEXT(&quot;&quot;), 64 );
					break;

				case IDD_RECV:
					MessageBox ( hWnd, TEXT(&quot;Datei empfangen&quot;), TEXT(&quot;&quot;), 64 );
					break;

				case IDD_SCANNER:	
					//MessageBox ( hWnd, TEXT(&quot;Datei scannen&quot;), TEXT(&quot;&quot;), 64 );

					g_hwndScann = CreateDialog( g_hInst, MAKEINTRESOURCE(IDD_SCAN), hWnd, (DLGPROC)ScanProc );

					if ( g_hwndScann )
					{
						ShowWindow(g_hwndScann, SW_SHOW);
					}
					else
					{
						MessageBox ( hWnd, TEXT(&quot;Scan dialog failed&quot;), TEXT(&quot;&quot;), 64 );
						return 0;
					}
					break;

				case IDD_EXIT:
					PostQuitMessage(0);
					break;

				default:
				   return DefWindowProc(hWnd, message, wParam, lParam);
			}
			break;

		case WM_CREATE:
			hSendFile = CreateWindow  (TEXT(&quot;BUTTON&quot;), 
									   TEXT(&quot;Datei senden&quot;), 
									   WS_VISIBLE | BS_PUSHBUTTON | WS_BORDER | WS_CHILD, 
									   0, 30, 
									   cx, 50,
									   (HWND)hWnd,
									   (HMENU)IDD_SEND, 
									   g_hInst,
									   NULL );

			hRecvFile = CreateWindow  (TEXT(&quot;BUTTON&quot;), 
									   TEXT(&quot;Datei empfangen&quot;), 
									   WS_VISIBLE | BS_PUSHBUTTON | WS_BORDER | WS_CHILD, 
									   0, 120, 
									   cx, 50,
									   (HWND)hWnd,
									   (HMENU)IDD_RECV, 
									   g_hInst,
									   NULL );

			hScan =		CreateWindow  (TEXT(&quot;BUTTON&quot;), 
									   TEXT(&quot;Scannvorgang durchführen&quot;), 
									   WS_VISIBLE | BS_PUSHBUTTON | WS_BORDER | WS_CHILD, 
									   0, 200, 
									   cx, 50,
									   (HWND)hWnd,
									   (HMENU)IDD_SCANNER, 
									   g_hInst,
									   NULL );
			break;

		case WM_DESTROY:
			PostQuitMessage(0);
			return 0;

		default:
			return DefWindowProc(hWnd, message, wParam, lParam);
   }

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

LRESULT CALLBACK ScanProc( HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam )
{
	SHINITDLGINFO shidi;

	switch (message)
	{
		case WM_INITDIALOG:
			return TRUE; 

		case WM_COMMAND:
			switch( LOWORD(wParam) )
			{
				case IDOK:

					EndDialog( hDlg, LOWORD(wParam) );
					return TRUE;

				case IDCLOSE:
					EndDialog( hDlg, LOWORD(wParam) );
					return TRUE;

				default:
					break;
			}

			break;
		case WM_DESTROY: 
			ShowWindow ( hDlg, SW_HIDE );
			break;
	}
    return FALSE;
}

LRESULT CALLBACK AboutProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
	switch (message)
	{
		case WM_INITDIALOG:
			return TRUE; 

		case WM_COMMAND:
			if (LOWORD(wParam) == IDOK)
			{
				EndDialog(hDlg, LOWORD(wParam));
				MessageBox ( hDlg, TEXT(&quot;ok gedrückt in about&quot;), TEXT(&quot;&quot;), 64 );
				return TRUE;
			}
			break;
	}
    return FALSE;
}
</code></pre>
<p>Was mache ich da bloß falsch?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1050904</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1050904</guid><dc:creator><![CDATA[Klaus23]]></dc:creator><pubDate>Thu, 04 May 2006 13:49:41 GMT</pubDate></item><item><title><![CDATA[Reply to Dialog schließt ganzes Programm on Thu, 04 May 2006 14:05:53 GMT]]></title><description><![CDATA[<p>Du rufst bei WM_Command die DefWindowProc() auf. Bei Menüaufrufen ist das gar nicht nötig.</p>
<p>im switch(message) rufst Du ebenfalls im default-Zweig hinter den CreateWindowEx() die DefWindowProc auf. Das ist auch nicht nötig.</p>
<p>Die Standardbearbeitung sollte eigentlich AFAIK nur beim Abschluß der WndProc aufgerufen werden, wenn alles andere beendet ist. Setz doch bei den vorherigen Aufrufen einfach mal return(0)ein.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1050918</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1050918</guid><dc:creator><![CDATA[Elektronix]]></dc:creator><pubDate>Thu, 04 May 2006 14:05:53 GMT</pubDate></item><item><title><![CDATA[Reply to Dialog schließt ganzes Programm on Thu, 04 May 2006 14:18:10 GMT]]></title><description><![CDATA[<p>So,</p>
<p>auch das lider wieder ohne Erfolg.<br />
Ich verstehe es nicht.<br />
Er sollte doch bei dem Scan Dialog wenn ich auf das X klicke,<br />
im ScanProc im Close landen.</p>
<p>Wieso tut er es nicht?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1050926</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1050926</guid><dc:creator><![CDATA[Klaus23]]></dc:creator><pubDate>Thu, 04 May 2006 14:18:10 GMT</pubDate></item><item><title><![CDATA[Reply to Dialog schließt ganzes Programm on Thu, 04 May 2006 14:50:26 GMT]]></title><description><![CDATA[<p>Versuchs doch mal so: bei</p>
<pre><code>case IDCLOSE:
EndDialog( hDlg, IDCANCEL );
break;
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1050948</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1050948</guid><dc:creator><![CDATA[Elektronix]]></dc:creator><pubDate>Thu, 04 May 2006 14:50:26 GMT</pubDate></item><item><title><![CDATA[Reply to Dialog schließt ganzes Programm on Fri, 05 May 2006 06:12:28 GMT]]></title><description><![CDATA[<p>Jetzt ist es mit klar. &lt;handvordenkopfschlag&gt;</p>
<p>Du hast ja einen nicht modalen Dialog erzeugt!</p>
<p>Den nicht Modalen Dialog darfst Du in keinem Fall mit EndDiaog beenden! Der nicht modale Dialog wird einfach zerstört mit DestroyWindow!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1051188</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1051188</guid><dc:creator><![CDATA[Martin Richter]]></dc:creator><pubDate>Fri, 05 May 2006 06:12:28 GMT</pubDate></item><item><title><![CDATA[Reply to Dialog schließt ganzes Programm on Fri, 05 May 2006 07:24:13 GMT]]></title><description><![CDATA[<p>Oh ja,</p>
<p>das war es. <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f644.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--face_with_rolling_eyes"
      title=":rolling_eyes:"
      alt="🙄"
    /><br />
Jetzt klappt es, vielen Dank. Dann haben die das in dem Tutorial was ich da gefunden hatte, aber ebenso falsch gemacht. grml</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1051224</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1051224</guid><dc:creator><![CDATA[Klaus23]]></dc:creator><pubDate>Fri, 05 May 2006 07:24:13 GMT</pubDate></item><item><title><![CDATA[Reply to Dialog schließt ganzes Programm on Fri, 05 May 2006 07:52:01 GMT]]></title><description><![CDATA[<p>Klaus23 schrieb:</p>
<blockquote>
<p>Jetzt klappt es, vielen Dank. Dann haben die das in dem Tutorial was ich da gefunden hatte, aber ebenso falsch gemacht. grml</p>
</blockquote>
<p>Vielleicht haben Die aber auch einen modalen Dialog erzeugt und Du hast einen nciht modalen draus gemacht... &lt;duck&amp;wech&gt;</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1051253</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1051253</guid><dc:creator><![CDATA[Martin Richter]]></dc:creator><pubDate>Fri, 05 May 2006 07:52:01 GMT</pubDate></item></channel></rss>