<?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[Selbstgezeichnete ProgressBar flackert...]]></title><description><![CDATA[<p>Hallo zusammen!</p>
<p>Zuerst einmal die Prozedur, die die ProgressBar steuert inkl. Zeichencode:</p>
<pre><code class="language-cpp">LRESULT CALLBACK MENCODER::ProgressProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
	UNREFERENCED_PARAMETER(lParam);
	HDC hdc;
	PAINTSTRUCT ps;

	HBRUSH hbrBcknd = CreateSolidBrush(RGB(224,224,224));
	HBRUSH hbrFill = CreateSolidBrush(RGB(255,127,0));
	RECT rPB;
	RECT rFill;
	int iStatus;

	switch (message)
	{
	case WM_PAINT:
		{
			iStatus = (int) wParam;
			GetClientRect(hDlg, &amp;rPB);
			hdc = BeginPaint(hDlg, &amp;ps);
			FillRect(hdc, &amp;rPB,hbrBcknd);
			char cStatusText[10];
			sprintf(cStatusText, &quot;%d%%&quot;, iStatus);

			float fStep = (rPB.right - rPB.left) / 100.0f;
			rFill = rPB;
			rFill.right = fStep * iStatus;
			FillRect(hdc, &amp;rFill, hbrFill);

			SetBkMode(hdc, TRANSPARENT);
			//DrawText(hdc, cStatusText, strlen(cStatusText), &amp;rPB, DT_CENTER);
			EndPaint(hDlg, &amp;ps);
			DeleteObject(hdc);
			DeleteObject(hbrBcknd);
			DeleteObject(hbrFill);
			return 0;
		}break;

	case WM_ERASEBKGND:
		{
			return 1;
		}break;
	}
	return TRUE;
}
</code></pre>
<p>Das Problem an der Sache ist nun, dass die ProgressBar ständig flackert, bzw einfach nur weiß wird, wenn der Status für einen kleinen Zeitraum nicht fortschreitet. Kann mir jemand sagen, wie ich das vermeiden kann?</p>
<p>Grüße veryxRV</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/196251/selbstgezeichnete-progressbar-flackert</link><generator>RSS for Node</generator><lastBuildDate>Wed, 17 Jun 2026 00:54:15 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/196251.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 27 Oct 2007 12:15:55 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Selbstgezeichnete ProgressBar flackert... on Sat, 27 Oct 2007 12:15:55 GMT]]></title><description><![CDATA[<p>Hallo zusammen!</p>
<p>Zuerst einmal die Prozedur, die die ProgressBar steuert inkl. Zeichencode:</p>
<pre><code class="language-cpp">LRESULT CALLBACK MENCODER::ProgressProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
	UNREFERENCED_PARAMETER(lParam);
	HDC hdc;
	PAINTSTRUCT ps;

	HBRUSH hbrBcknd = CreateSolidBrush(RGB(224,224,224));
	HBRUSH hbrFill = CreateSolidBrush(RGB(255,127,0));
	RECT rPB;
	RECT rFill;
	int iStatus;

	switch (message)
	{
	case WM_PAINT:
		{
			iStatus = (int) wParam;
			GetClientRect(hDlg, &amp;rPB);
			hdc = BeginPaint(hDlg, &amp;ps);
			FillRect(hdc, &amp;rPB,hbrBcknd);
			char cStatusText[10];
			sprintf(cStatusText, &quot;%d%%&quot;, iStatus);

			float fStep = (rPB.right - rPB.left) / 100.0f;
			rFill = rPB;
			rFill.right = fStep * iStatus;
			FillRect(hdc, &amp;rFill, hbrFill);

			SetBkMode(hdc, TRANSPARENT);
			//DrawText(hdc, cStatusText, strlen(cStatusText), &amp;rPB, DT_CENTER);
			EndPaint(hDlg, &amp;ps);
			DeleteObject(hdc);
			DeleteObject(hbrBcknd);
			DeleteObject(hbrFill);
			return 0;
		}break;

	case WM_ERASEBKGND:
		{
			return 1;
		}break;
	}
	return TRUE;
}
</code></pre>
<p>Das Problem an der Sache ist nun, dass die ProgressBar ständig flackert, bzw einfach nur weiß wird, wenn der Status für einen kleinen Zeitraum nicht fortschreitet. Kann mir jemand sagen, wie ich das vermeiden kann?</p>
<p>Grüße veryxRV</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1392981</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1392981</guid><dc:creator><![CDATA[veryxRV]]></dc:creator><pubDate>Sat, 27 Oct 2007 12:15:55 GMT</pubDate></item><item><title><![CDATA[Reply to Selbstgezeichnete ProgressBar flackert... on Sat, 27 Oct 2007 12:43:49 GMT]]></title><description><![CDATA[<ol>
<li>Backbuffer verwenden</li>
<li>WM_PAINT nur auslösen, wenn sich der Balken überhaupt weiter bewegt</li>
<li>DeleteObject(hdc); ist falsch: Wenn dann DeleteDC(), was aber auch falsch ist da EndPaint() das schon übernimmt.</li>
</ol>
<p>Würde es nicht Sinn machen die HBRUSH-Dinger static zu deklarieren und nur z.B. bei WM_CREATE zu initialisieren?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1393003</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1393003</guid><dc:creator><![CDATA[geeky]]></dc:creator><pubDate>Sat, 27 Oct 2007 12:43:49 GMT</pubDate></item><item><title><![CDATA[Reply to Selbstgezeichnete ProgressBar flackert... on Sat, 27 Oct 2007 13:03:33 GMT]]></title><description><![CDATA[<p>Danke für deine Antwort!</p>
<p>Leider scheint auch ein Backbuffer das Problem nicht zu lösen. Da die ProgressBar in einem ListView gezeichnet wird, das sich ständig ändert, muss auch die PB mit jeder Änderung des ListView neu gezeichnet werden, es reicht also nicht, sie nur dann neu zu zeichnen, wenn sich der Status ändert.</p>
<p>Gibt es vielleicht noch andere Möglichkeiten?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1393017</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1393017</guid><dc:creator><![CDATA[veryxRV]]></dc:creator><pubDate>Sat, 27 Oct 2007 13:03:33 GMT</pubDate></item><item><title><![CDATA[Reply to Selbstgezeichnete ProgressBar flackert... on Sat, 27 Oct 2007 13:05:59 GMT]]></title><description><![CDATA[<p>Es vermindert zumindest schonmal das flackern das dir FillRect() produziert, und du verkürzt dadurch bei keiner Änderung die Zeit zum neu zeichnen, da du lediglich den backbuffer blitten musst statt 2x FillRect und DrawtText().</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1393020</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1393020</guid><dc:creator><![CDATA[geeky]]></dc:creator><pubDate>Sat, 27 Oct 2007 13:05:59 GMT</pubDate></item><item><title><![CDATA[Reply to Selbstgezeichnete ProgressBar flackert... on Sat, 27 Oct 2007 13:07:33 GMT]]></title><description><![CDATA[<p>Ja, das ist schon mal gut, nur wie bekomme ich das Flackern ganz weg?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1393022</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1393022</guid><dc:creator><![CDATA[veryxRV]]></dc:creator><pubDate>Sat, 27 Oct 2007 13:07:33 GMT</pubDate></item><item><title><![CDATA[Reply to Selbstgezeichnete ProgressBar flackert... on Sat, 27 Oct 2007 13:09:59 GMT]]></title><description><![CDATA[<p>Dann musst du irgendwie die ListView dazu bringen die Stelle wo dein Control sitzt nicht neu zu zeichnen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1393025</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1393025</guid><dc:creator><![CDATA[geeky]]></dc:creator><pubDate>Sat, 27 Oct 2007 13:09:59 GMT</pubDate></item><item><title><![CDATA[Reply to Selbstgezeichnete ProgressBar flackert... on Sat, 27 Oct 2007 13:20:33 GMT]]></title><description><![CDATA[<p>Gibt es da nicht irendeinen Wert, den ich der ProgressBar mitgeben kann, der Bewirkt, dass sie sich sozusagen &quot;im Vordergrund&quot; befindet, also das ListView &quot;darunter&quot; gezeichnet wird?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1393036</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1393036</guid><dc:creator><![CDATA[veryxRV]]></dc:creator><pubDate>Sat, 27 Oct 2007 13:20:33 GMT</pubDate></item><item><title><![CDATA[Reply to Selbstgezeichnete ProgressBar flackert... on Sat, 27 Oct 2007 17:27:37 GMT]]></title><description><![CDATA[<p>Kann es evtl sein, dass das ParentWindow neu gezeichnet wird, sobald man das ChildWindow neu zeichnet?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1393183</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1393183</guid><dc:creator><![CDATA[veryxRV]]></dc:creator><pubDate>Sat, 27 Oct 2007 17:27:37 GMT</pubDate></item></channel></rss>