<?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 funktioniert nicht vernünftig]]></title><description><![CDATA[<p>Hallo Community.</p>
<p>Ich bin grade dabei, ein kleinen Dialog zu schreiben.</p>
<p>Nun habe ich eine Resource IDD_MAIN mit einem leeren Dialog. Dort ist</p>
<pre><code class="language-cpp">IDD_MAIN DIALOGEX 6,6,194,103
CAPTION &quot;Share Timer&quot;
FONT 8,&quot;MS Sans Serif&quot;,0,0
STYLE 0x10CF0000
CLASS &quot;ShareTimer&quot;
BEGIN
END
</code></pre>
<p>Nun habe ich die Klasse, in der der Dialog aufgerufen werden soll:</p>
<pre><code class="language-cpp">#define _WIN32_WINNT 0x0510
#include &lt;windows.h&gt;

#include &quot;MainWnd.h&quot;
#include &quot;script.h&quot;

CMainWnd::CMainWnd(HINSTANCE hInst)
{
	hInstance = hInst;

	// As first fill the class structure
	wcWnd.cbSize          = sizeof(WNDCLASSEX);
	wcWnd.style           = CS_HREDRAW | CS_VREDRAW;
	wcWnd.lpfnWndProc     = StaticWndProc;
	wcWnd.cbClsExtra      = 0;
	wcWnd.cbWndExtra      = DLGWINDOWEXTRA;
	wcWnd.hInstance       = hInstance;
	wcWnd.hIcon           = LoadIcon(NULL, IDI_APPLICATION);
	wcWnd.hCursor         = LoadCursor(NULL, IDC_ARROW);
	wcWnd.hbrBackground   = (HBRUSH)GetStockObject(WHITE_BRUSH);
	wcWnd.lpszMenuName    = NULL;
	wcWnd.lpszClassName   = &quot;ShareTimer&quot;;
	wcWnd.hIconSm         = wcWnd.hIcon;

	if (!RegisterClassEx(&amp;wcWnd))
	{
		return;
	}

	hWnd = CreateDialogParam(hInstance,
							 MAKEINTRESOURCE(IDD_MAIN),
							 NULL,
							 NULL,
							 (LPARAM)this);

	// Show the window
	ShowWindow(hWnd, 1);
	UpdateWindow(hWnd);
}

CMainWnd::~CMainWnd(void)
{
}

LRESULT CALLBACK CMainWnd::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
	HDC hPaintDC;
	PAINTSTRUCT ps;

	switch (uMsg)
	{
	case WM_CREATE:
		Beep(440,1000);
		return 0;

	case WM_PAINT:
		hPaintDC = BeginPaint(hWnd, &amp;ps);

		EndPaint(hWnd, &amp;ps);
		return 0;

	case WM_DESTROY:
		PostQuitMessage(0);
		return 0;
	}

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

LRESULT CALLBACK CMainWnd::StaticWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
	if (uMsg == WM_CREATE)
	{
		SetWindowLong(hWnd,GWL_USERDATA,(LONG)((LPCREATESTRUCT)lParam) -&gt; lpCreateParams);
	}

	CMainWnd *pThis = (CMainWnd *) GetWindowLong(hWnd,GWL_USERDATA);

	if (pThis == 0)
	{
		return DefWindowProc(hWnd,uMsg,wParam,lParam);
	}
	else
	{
		return pThis-&gt;WndProc(hWnd,uMsg,wParam,lParam);
	}
}
</code></pre>
<p>Das wird auch ohne Mucken kompiliert, aber sobald ich den Debug starte, treten folgende Probleme auf:</p>
<p>1. Der Dialog hat eine weiße hintergrundfarbe, ich will aber die Farben vom Windows-Theme haben!</p>
<p>2. Wenn ich auf schließen klicke, geht der Prozess nicht aus, die Message-Schleife ist die eines standard Windowsfenster.</p>
<p>Das liegt daran, habe ich schon herausgefunden, dass der garnicht bis zur WndProc sondern nur WndProcStatic kommt.</p>
<p>Könnt ihr mir mal daran behilflich sein?</p>
<p>Danke. <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>
]]></description><link>https://www.c-plusplus.net/forum/topic/192535/dialog-funktioniert-nicht-vernünftig</link><generator>RSS for Node</generator><lastBuildDate>Tue, 30 Jun 2026 20:02:56 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/192535.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 15 Sep 2007 17:37:54 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Dialog funktioniert nicht vernünftig on Sat, 15 Sep 2007 17:37:54 GMT]]></title><description><![CDATA[<p>Hallo Community.</p>
<p>Ich bin grade dabei, ein kleinen Dialog zu schreiben.</p>
<p>Nun habe ich eine Resource IDD_MAIN mit einem leeren Dialog. Dort ist</p>
<pre><code class="language-cpp">IDD_MAIN DIALOGEX 6,6,194,103
CAPTION &quot;Share Timer&quot;
FONT 8,&quot;MS Sans Serif&quot;,0,0
STYLE 0x10CF0000
CLASS &quot;ShareTimer&quot;
BEGIN
END
</code></pre>
<p>Nun habe ich die Klasse, in der der Dialog aufgerufen werden soll:</p>
<pre><code class="language-cpp">#define _WIN32_WINNT 0x0510
#include &lt;windows.h&gt;

#include &quot;MainWnd.h&quot;
#include &quot;script.h&quot;

CMainWnd::CMainWnd(HINSTANCE hInst)
{
	hInstance = hInst;

	// As first fill the class structure
	wcWnd.cbSize          = sizeof(WNDCLASSEX);
	wcWnd.style           = CS_HREDRAW | CS_VREDRAW;
	wcWnd.lpfnWndProc     = StaticWndProc;
	wcWnd.cbClsExtra      = 0;
	wcWnd.cbWndExtra      = DLGWINDOWEXTRA;
	wcWnd.hInstance       = hInstance;
	wcWnd.hIcon           = LoadIcon(NULL, IDI_APPLICATION);
	wcWnd.hCursor         = LoadCursor(NULL, IDC_ARROW);
	wcWnd.hbrBackground   = (HBRUSH)GetStockObject(WHITE_BRUSH);
	wcWnd.lpszMenuName    = NULL;
	wcWnd.lpszClassName   = &quot;ShareTimer&quot;;
	wcWnd.hIconSm         = wcWnd.hIcon;

	if (!RegisterClassEx(&amp;wcWnd))
	{
		return;
	}

	hWnd = CreateDialogParam(hInstance,
							 MAKEINTRESOURCE(IDD_MAIN),
							 NULL,
							 NULL,
							 (LPARAM)this);

	// Show the window
	ShowWindow(hWnd, 1);
	UpdateWindow(hWnd);
}

CMainWnd::~CMainWnd(void)
{
}

LRESULT CALLBACK CMainWnd::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
	HDC hPaintDC;
	PAINTSTRUCT ps;

	switch (uMsg)
	{
	case WM_CREATE:
		Beep(440,1000);
		return 0;

	case WM_PAINT:
		hPaintDC = BeginPaint(hWnd, &amp;ps);

		EndPaint(hWnd, &amp;ps);
		return 0;

	case WM_DESTROY:
		PostQuitMessage(0);
		return 0;
	}

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

LRESULT CALLBACK CMainWnd::StaticWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
	if (uMsg == WM_CREATE)
	{
		SetWindowLong(hWnd,GWL_USERDATA,(LONG)((LPCREATESTRUCT)lParam) -&gt; lpCreateParams);
	}

	CMainWnd *pThis = (CMainWnd *) GetWindowLong(hWnd,GWL_USERDATA);

	if (pThis == 0)
	{
		return DefWindowProc(hWnd,uMsg,wParam,lParam);
	}
	else
	{
		return pThis-&gt;WndProc(hWnd,uMsg,wParam,lParam);
	}
}
</code></pre>
<p>Das wird auch ohne Mucken kompiliert, aber sobald ich den Debug starte, treten folgende Probleme auf:</p>
<p>1. Der Dialog hat eine weiße hintergrundfarbe, ich will aber die Farben vom Windows-Theme haben!</p>
<p>2. Wenn ich auf schließen klicke, geht der Prozess nicht aus, die Message-Schleife ist die eines standard Windowsfenster.</p>
<p>Das liegt daran, habe ich schon herausgefunden, dass der garnicht bis zur WndProc sondern nur WndProcStatic kommt.</p>
<p>Könnt ihr mir mal daran behilflich sein?</p>
<p>Danke. <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>
]]></description><link>https://www.c-plusplus.net/forum/post/1366023</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1366023</guid><dc:creator><![CDATA[MasterODesaster]]></dc:creator><pubDate>Sat, 15 Sep 2007 17:37:54 GMT</pubDate></item><item><title><![CDATA[Reply to Dialog funktioniert nicht vernünftig on Sat, 15 Sep 2007 18:02:45 GMT]]></title><description><![CDATA[<p>Du darfst eine &quot;DialogProc&quot; nicht mit einer &quot;WndProc&quot; verwechseln :</p>
<pre><code class="language-cpp">BOOL CALLBACK DialogProc(

 HWND hwndDlg,     // handle to dialog box
 UINT uMsg,        // message
 WPARAM wParam,    // first message parameter
 LPARAM lParam     // second message parameter

);
</code></pre>
<p>DialogProc schrieb:</p>
<blockquote>
<p><strong>Return Values</strong><br />
...the dialog box procedure should return nonzero if it processes the message, and zero if it does not.</p>
</blockquote>
<p>Sie verhält sich gewissermassen &quot;um 180 Grad verkehrt&quot;.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1366038</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1366038</guid><dc:creator><![CDATA[[[global:guest]]]]></dc:creator><pubDate>Sat, 15 Sep 2007 18:02:45 GMT</pubDate></item><item><title><![CDATA[Reply to Dialog funktioniert nicht vernünftig on Sun, 16 Sep 2007 10:15:36 GMT]]></title><description><![CDATA[<p>Ooooh! Na gut, dann werde ich halt eine DlgProc verwenden.</p>
<p>Aber in der WNDCLASSEX ist doch noch ein WHITE_BRUSH. Was mach ich mit dem?</p>
<p>Und wie bekomme ich die DlgProc nicht &quot;static&quot;? Eigentlich wollte ich dafür CreateDialogParam verwenden.</p>
<p>Bis spädda. <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>
]]></description><link>https://www.c-plusplus.net/forum/post/1366208</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1366208</guid><dc:creator><![CDATA[Script-Styler]]></dc:creator><pubDate>Sun, 16 Sep 2007 10:15:36 GMT</pubDate></item><item><title><![CDATA[Reply to Dialog funktioniert nicht vernünftig on Sun, 16 Sep 2007 11:26:57 GMT]]></title><description><![CDATA[<p>Sorry für den DoppelPost, aber ich habe einen neuen Versuch gestartet.</p>
<pre><code class="language-cpp">#define _WIN32_WINNT 0x0510
#include &lt;windows.h&gt;

#include &quot;MainWnd.h&quot;
#include &quot;script.h&quot;

CMainWnd::CMainWnd(HINSTANCE hInst)
{
	hInstance = hInst;

	DialogBoxParam(hInstance, MAKEINTRESOURCE(IDD_MAIN), NULL, StaticProc, (long)this);
}

CMainWnd::~CMainWnd(void)
{
}

INT_PTR CALLBACK CMainWnd::DialogProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
	switch (message)
	{
	case WM_INITDIALOG:
		return 0;
	case WM_CLOSE:
		EndDialog(hDlg, IDOK);
		return 0;
	case WM_COMMAND:
		switch (LOWORD(wParam))
		{
		case IDOK:
			EndDialog(hDlg, IDOK);
			return 0;
		}
		return 0;
	}
	return 0;
}

INT_PTR CALLBACK CMainWnd::StaticProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
	static CMainWnd *pThis;

	if (message = WM_INITDIALOG)
	{
		pThis = (CMainWnd*)lParam;
	}

	if (pThis)
		return pThis-&gt;DialogProc(hDlg, message, wParam, lParam);
	else
		return 0;
}
</code></pre>
<p>Jedoch lässt sich das Fenster nicht schließen. ich weiß auch nicht warum, aber die Messages kommen in der &quot;unstatic&quot; an.</p>
<p>Danke. <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>
]]></description><link>https://www.c-plusplus.net/forum/post/1366252</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1366252</guid><dc:creator><![CDATA[Script-Styler]]></dc:creator><pubDate>Sun, 16 Sep 2007 11:26:57 GMT</pubDate></item><item><title><![CDATA[Reply to Dialog funktioniert nicht vernünftig on Sun, 16 Sep 2007 14:20:56 GMT]]></title><description><![CDATA[<p>Ein Klick auf das Dialog-X sendet eine WM_COMMAND-Message an den Dialog mit HIWORD(wParam)==IDCANCEL <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/1366370</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1366370</guid><dc:creator><![CDATA[a]]></dc:creator><pubDate>Sun, 16 Sep 2007 14:20:56 GMT</pubDate></item><item><title><![CDATA[Reply to Dialog funktioniert nicht vernünftig on Sun, 16 Sep 2007 14:21:06 GMT]]></title><description><![CDATA[<p>:push:<br />
keiner ne idee?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1366371</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1366371</guid><dc:creator><![CDATA[Script-Styler]]></dc:creator><pubDate>Sun, 16 Sep 2007 14:21:06 GMT</pubDate></item><item><title><![CDATA[Reply to Dialog funktioniert nicht vernünftig on Sun, 16 Sep 2007 14:21:52 GMT]]></title><description><![CDATA[<p>(LOWORD(wParam)==IDCANCEL natürlich)</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1366373</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1366373</guid><dc:creator><![CDATA[a]]></dc:creator><pubDate>Sun, 16 Sep 2007 14:21:52 GMT</pubDate></item><item><title><![CDATA[Reply to Dialog funktioniert nicht vernünftig on Sun, 16 Sep 2007 14:43:03 GMT]]></title><description><![CDATA[<p>es liegt an der Static Proc.</p>
<p>Denn wenn ich den Inhalt der DlgProc in die StaticProc packe, funktionierts.</p>
<p>komisch. liegt es an dem Static der Variable im StaticProc?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1366384</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1366384</guid><dc:creator><![CDATA[Script-Styler]]></dc:creator><pubDate>Sun, 16 Sep 2007 14:43:03 GMT</pubDate></item><item><title><![CDATA[Reply to Dialog funktioniert nicht vernünftig on Sun, 16 Sep 2007 15:06:35 GMT]]></title><description><![CDATA[<p>Naja, nach ein bisschen probben gehts.</p>
<p>ich habe jetzt zwei methoden, wie man es machen könnte.</p>
<p>Welche ist besser?</p>
<p>// Set/Get</p>
<pre><code class="language-cpp">{
	CMainWnd *pThis;

	if (message == WM_INITDIALOG)
	{
		SetWindowLong(hDlg, GWL_USERDATA, (LONG)((LPCREATESTRUCT)lParam) -&gt; lpCreateParams);
	}

	pThis = (CMainWnd *) GetWindowLong(hDlg, GWL_USERDATA);

	if (pThis == 0)
		return 0,;
	else
		return pThis-&gt;DialogProc(hDlg, message, wParam, lParam);
}
</code></pre>
<p>// Static in static</p>
<pre><code class="language-cpp">{
	static CMainWnd *pThis;

	if (message == WM_INITDIALOG)
	{
		// Fill static
		pThis = (CMainWnd *) (LONG)((LPCREATESTRUCT)lParam) -&gt; lpCreateParams;
	}

	if (pThis == 0)
		return 0;
	else
		return pThis-&gt;DialogProc(hDlg, message, wParam, lParam);
}
</code></pre>
<p>Sind beide gut? hat die Static eine bessere performance, da weniger Funktionsaufruf?</p>
<p>Danke.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1366386</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1366386</guid><dc:creator><![CDATA[Script-Styler]]></dc:creator><pubDate>Sun, 16 Sep 2007 15:06:35 GMT</pubDate></item><item><title><![CDATA[Reply to Dialog funktioniert nicht vernünftig on Sun, 16 Sep 2007 20:33:50 GMT]]></title><description><![CDATA[<p>Bitte ankreuzen :</p>
<p>&quot;return 0&quot; in einer DialogProc bedeutet, dass die Botschaft</p>
<p><div class="plugin-markdown"><input type="checkbox" id="checkbox192550" /><label for="checkbox192550">selbst behandelt wurde und das Betriebssystem keine DefaultProc aufrufen soll.</label></div><br />
<div class="plugin-markdown"><input type="checkbox" id="checkbox192549" /><label for="checkbox192549">nicht selbst behandelt wurde und das Betriebssystem eine entsprechende DefaultProc aufrufen soll.</label></div></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1366625</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1366625</guid><dc:creator><![CDATA[[[global:guest]]]]></dc:creator><pubDate>Sun, 16 Sep 2007 20:33:50 GMT</pubDate></item><item><title><![CDATA[Reply to Dialog funktioniert nicht vernünftig on Mon, 17 Sep 2007 09:20:15 GMT]]></title><description><![CDATA[<p>merker schrieb:</p>
<blockquote>
<p>Bitte ankreuzen :</p>
<p>&quot;return 0&quot; in einer DialogProc bedeutet, dass die Botschaft</p>
<p>[ X ] selbst behandelt wurde und das Betriebssystem keine DefaultProc aufrufen soll.<br />
<div class="plugin-markdown"><input type="checkbox" id="checkbox192551" /><label for="checkbox192551">nicht selbst behandelt wurde und das Betriebssystem eine entsprechende DefaultProc aufrufen soll.</label></div></p>
</blockquote>
<p>Dann eben DefDlgProc...</p>
<p>Abner was ist denn besser?</p>
<p>[] Static variante<br />
[] Get/Set WindowLong methode</p>
<p>Tja.</p>
<p>Back to topic:</p>
<p>Der Dialog in Klasse funzt super.</p>
<p>Wenn ich ihn in der WinMain aufrufe.</p>
<p>Aber wenn ich ihn in der DialogProc des Main-Dialogs aufrufe, kommt er nicht.</p>
<p>Woran kann das liegen? Also ich weiß sicher, dass Die Funktion aufgerufen wird, aber der Dialog kommt nicht.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1366773</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1366773</guid><dc:creator><![CDATA[Script-Styler]]></dc:creator><pubDate>Mon, 17 Sep 2007 09:20:15 GMT</pubDate></item></channel></rss>