<?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[DoModal in wincore.cpp]]></title><description><![CDATA[<p>Mein Programm stürzt regelmäßig ab (assertion), wenn ich die im DEBUG_Modus bin, RELEASE läuft einwandfrei. Ich habe das Problem zurückverfolgt bis zur ersten &quot;ASSERT(ContinueModal());&quot; Zeile im RunModalLoop.<br />
Jetzt frage ich mich, was hat diese Überprüfung für einen Sinn?<br />
In der Releaseversion wird diese Prüfung nicht vorgenommen, und vor allem: Es ist doch ganz normal, dass ContinueModal irgendwann false liefert, oder etwa nicht?</p>
<p>Ich habe schon stundenlang diesen Microsoft Code analysiert, aber komme zu keiner sinnvollen Verwendung für diese Assertions. Weiß einer Rat?<br />
Danke!</p>
<p>===============================================================================<br />
Jetzt folgt der zugehörige Codeausschnit aus der wincore.cpp</p>
<pre><code>int CWnd::RunModalLoop(DWORD dwFlags)
{
	ASSERT(::IsWindow(m_hWnd)); // window must be created
	ASSERT(!(m_nFlags &amp; WF_MODALLOOP)); // window must not already be in modal state

	// for tracking the idle time state
	BOOL bIdle = TRUE;
	LONG lIdleCount = 0;
	BOOL bShowIdle = (dwFlags &amp; MLF_SHOWONIDLE) &amp;&amp; !(GetStyle() &amp; WS_VISIBLE);
	HWND hWndParent = ::GetParent(m_hWnd);
	m_nFlags |= (WF_MODALLOOP|WF_CONTINUEMODAL);
	MSG* pMsg = &amp;AfxGetThread()-&gt;m_msgCur;

	// acquire and dispatch messages until the modal state is done
	for (;;)
	{
		ASSERT(ContinueModal());

		// phase1: check to see if we can do idle work
		while (bIdle &amp;&amp;
			!::PeekMessage(pMsg, NULL, NULL, NULL, PM_NOREMOVE))
		{
			ASSERT(ContinueModal());

			// show the dialog when the message queue goes idle
			if (bShowIdle)
			{
				ShowWindow(SW_SHOWNORMAL);
				UpdateWindow();
				bShowIdle = FALSE;
			}

			// call OnIdle while in bIdle state
			if (!(dwFlags &amp; MLF_NOIDLEMSG) &amp;&amp; hWndParent != NULL &amp;&amp; lIdleCount == 0)
			{
				// send WM_ENTERIDLE to the parent
				::SendMessage(hWndParent, WM_ENTERIDLE, MSGF_DIALOGBOX, (LPARAM)m_hWnd);
			}
			if ((dwFlags &amp; MLF_NOKICKIDLE) ||
				!SendMessage(WM_KICKIDLE, MSGF_DIALOGBOX, lIdleCount++))
			{
				// stop idle processing next time
				bIdle = FALSE;
			}
		}

		// phase2: pump messages while available
		do
		{
			ASSERT(ContinueModal());

			// pump message, but quit on WM_QUIT
			if (!AfxGetThread()-&gt;PumpMessage())
			{
				AfxPostQuitMessage(0);
				return -1;
			}

			// show the window when certain special messages rec'd
			if (bShowIdle &amp;&amp;
				(pMsg-&gt;message == 0x118 || pMsg-&gt;message == WM_SYSKEYDOWN))
			{
				ShowWindow(SW_SHOWNORMAL);
				UpdateWindow();
				bShowIdle = FALSE;
			}

			if (!ContinueModal())
				goto ExitModal;

			// reset &quot;no idle&quot; state after pumping &quot;normal&quot; message
			if (AfxGetThread()-&gt;IsIdleMessage(pMsg))
			{
				bIdle = TRUE;
				lIdleCount = 0;
			}

		} while (::PeekMessage(pMsg, NULL, NULL, NULL, PM_NOREMOVE));
	}

ExitModal:
	m_nFlags &amp;= ~(WF_MODALLOOP|WF_CONTINUEMODAL);
	return m_nModalResult;
}

BOOL CWnd::ContinueModal()
{
	return m_nFlags &amp; WF_CONTINUEMODAL;
}

void CWnd::EndModalLoop(int nResult)
{
	ASSERT(::IsWindow(m_hWnd));

	// this result will be returned from CWnd::RunModalLoop
	m_nModalResult = nResult;

	// make sure a message goes through to exit the modal loop
	if (m_nFlags &amp; WF_CONTINUEMODAL)
	{
		m_nFlags &amp;= ~WF_CONTINUEMODAL;
		PostMessage(WM_NULL);
	}
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/topic/190328/domodal-in-wincore-cpp</link><generator>RSS for Node</generator><lastBuildDate>Sat, 11 Apr 2026 17:00:58 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/190328.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 21 Aug 2007 15:45:31 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to DoModal in wincore.cpp on Tue, 21 Aug 2007 15:45:31 GMT]]></title><description><![CDATA[<p>Mein Programm stürzt regelmäßig ab (assertion), wenn ich die im DEBUG_Modus bin, RELEASE läuft einwandfrei. Ich habe das Problem zurückverfolgt bis zur ersten &quot;ASSERT(ContinueModal());&quot; Zeile im RunModalLoop.<br />
Jetzt frage ich mich, was hat diese Überprüfung für einen Sinn?<br />
In der Releaseversion wird diese Prüfung nicht vorgenommen, und vor allem: Es ist doch ganz normal, dass ContinueModal irgendwann false liefert, oder etwa nicht?</p>
<p>Ich habe schon stundenlang diesen Microsoft Code analysiert, aber komme zu keiner sinnvollen Verwendung für diese Assertions. Weiß einer Rat?<br />
Danke!</p>
<p>===============================================================================<br />
Jetzt folgt der zugehörige Codeausschnit aus der wincore.cpp</p>
<pre><code>int CWnd::RunModalLoop(DWORD dwFlags)
{
	ASSERT(::IsWindow(m_hWnd)); // window must be created
	ASSERT(!(m_nFlags &amp; WF_MODALLOOP)); // window must not already be in modal state

	// for tracking the idle time state
	BOOL bIdle = TRUE;
	LONG lIdleCount = 0;
	BOOL bShowIdle = (dwFlags &amp; MLF_SHOWONIDLE) &amp;&amp; !(GetStyle() &amp; WS_VISIBLE);
	HWND hWndParent = ::GetParent(m_hWnd);
	m_nFlags |= (WF_MODALLOOP|WF_CONTINUEMODAL);
	MSG* pMsg = &amp;AfxGetThread()-&gt;m_msgCur;

	// acquire and dispatch messages until the modal state is done
	for (;;)
	{
		ASSERT(ContinueModal());

		// phase1: check to see if we can do idle work
		while (bIdle &amp;&amp;
			!::PeekMessage(pMsg, NULL, NULL, NULL, PM_NOREMOVE))
		{
			ASSERT(ContinueModal());

			// show the dialog when the message queue goes idle
			if (bShowIdle)
			{
				ShowWindow(SW_SHOWNORMAL);
				UpdateWindow();
				bShowIdle = FALSE;
			}

			// call OnIdle while in bIdle state
			if (!(dwFlags &amp; MLF_NOIDLEMSG) &amp;&amp; hWndParent != NULL &amp;&amp; lIdleCount == 0)
			{
				// send WM_ENTERIDLE to the parent
				::SendMessage(hWndParent, WM_ENTERIDLE, MSGF_DIALOGBOX, (LPARAM)m_hWnd);
			}
			if ((dwFlags &amp; MLF_NOKICKIDLE) ||
				!SendMessage(WM_KICKIDLE, MSGF_DIALOGBOX, lIdleCount++))
			{
				// stop idle processing next time
				bIdle = FALSE;
			}
		}

		// phase2: pump messages while available
		do
		{
			ASSERT(ContinueModal());

			// pump message, but quit on WM_QUIT
			if (!AfxGetThread()-&gt;PumpMessage())
			{
				AfxPostQuitMessage(0);
				return -1;
			}

			// show the window when certain special messages rec'd
			if (bShowIdle &amp;&amp;
				(pMsg-&gt;message == 0x118 || pMsg-&gt;message == WM_SYSKEYDOWN))
			{
				ShowWindow(SW_SHOWNORMAL);
				UpdateWindow();
				bShowIdle = FALSE;
			}

			if (!ContinueModal())
				goto ExitModal;

			// reset &quot;no idle&quot; state after pumping &quot;normal&quot; message
			if (AfxGetThread()-&gt;IsIdleMessage(pMsg))
			{
				bIdle = TRUE;
				lIdleCount = 0;
			}

		} while (::PeekMessage(pMsg, NULL, NULL, NULL, PM_NOREMOVE));
	}

ExitModal:
	m_nFlags &amp;= ~(WF_MODALLOOP|WF_CONTINUEMODAL);
	return m_nModalResult;
}

BOOL CWnd::ContinueModal()
{
	return m_nFlags &amp; WF_CONTINUEMODAL;
}

void CWnd::EndModalLoop(int nResult)
{
	ASSERT(::IsWindow(m_hWnd));

	// this result will be returned from CWnd::RunModalLoop
	m_nModalResult = nResult;

	// make sure a message goes through to exit the modal loop
	if (m_nFlags &amp; WF_CONTINUEMODAL)
	{
		m_nFlags &amp;= ~WF_CONTINUEMODAL;
		PostMessage(WM_NULL);
	}
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1349173</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1349173</guid><dc:creator><![CDATA[jogijogi]]></dc:creator><pubDate>Tue, 21 Aug 2007 15:45:31 GMT</pubDate></item><item><title><![CDATA[Reply to DoModal in wincore.cpp on Tue, 21 Aug 2007 15:50:48 GMT]]></title><description><![CDATA[<p>vergessen:<br />
Ich starte einen neuen Arbeitsthread, rufe dann doModal für einen Wartedialog auf. Im ARbeitsthread wird ein bisschen gerechnet und anschließend ruft der Arbeitsthread EndDialog auf.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1349182</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1349182</guid><dc:creator><![CDATA[jogijogi]]></dc:creator><pubDate>Tue, 21 Aug 2007 15:50:48 GMT</pubDate></item></channel></rss>