<?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[DC Wiederherstellen]]></title><description><![CDATA[<p>Hi @ All.<br />
ich habe ein suppi proggy!<br />
Nur leider beendet sich dies ohne den Bildschirm zu säubern.<br />
wie kann man das ändern.</p>
<pre><code class="language-cpp">#include &lt;windows.h&gt;
#include &lt;math.h&gt;

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
                    LPSTR lpCmdLine, int nCmdShow)
{
	HDC		dc = GetDC(0);
	HPEN	hPen;
	HBRUSH	hBrush;
	RECT	rClient;
	double	sine;

	DWORD	runtime = 10000;
	DWORD	start = GetTickCount();
	DWORD	now = start;
	DWORD	tick = 0;

	GetClientRect(GetDesktopWindow(),&amp;rClient);

	int		x = rClient.left;
	int		y = rClient.top;
	int		width = rClient.right-rClient.left;
	int		height = rClient.bottom-rClient.top;

	hPen = CreatePen(PS_SOLID,(width &gt; height) ? width : height,RGB(255,255,255));
	hBrush = CreateSolidBrush(RGB(0,0,0));

	SelectObject(dc,hPen);
	SelectObject(dc,hBrush);
	while ((start + runtime &gt;= now) &amp;&amp; (now &gt;= start))
	{
		sine = 1 + sin((double)tick/(double)1000);

		Rectangle(dc,x+sine*width,
					y+sine*height,
					x+width-sine*width,
					y+height-sine*height);

		now = GetTickCount();
		tick = now - start;
	}
	return 0;
}
</code></pre>
<p>thx.</p>
<p>EDIT: Wie kann ich den Effekt etwas transparenter gestalten?<br />
Probiert ihn doch mal aus. 10 sekunden warten, wenn er zu ende ist, einfach mal die windows-taste drücken.</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/188285/dc-wiederherstellen</link><generator>RSS for Node</generator><lastBuildDate>Fri, 03 Jul 2026 18:29:44 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/188285.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 29 Jul 2007 23:19:52 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to DC Wiederherstellen on Sun, 29 Jul 2007 23:21:53 GMT]]></title><description><![CDATA[<p>Hi @ All.<br />
ich habe ein suppi proggy!<br />
Nur leider beendet sich dies ohne den Bildschirm zu säubern.<br />
wie kann man das ändern.</p>
<pre><code class="language-cpp">#include &lt;windows.h&gt;
#include &lt;math.h&gt;

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
                    LPSTR lpCmdLine, int nCmdShow)
{
	HDC		dc = GetDC(0);
	HPEN	hPen;
	HBRUSH	hBrush;
	RECT	rClient;
	double	sine;

	DWORD	runtime = 10000;
	DWORD	start = GetTickCount();
	DWORD	now = start;
	DWORD	tick = 0;

	GetClientRect(GetDesktopWindow(),&amp;rClient);

	int		x = rClient.left;
	int		y = rClient.top;
	int		width = rClient.right-rClient.left;
	int		height = rClient.bottom-rClient.top;

	hPen = CreatePen(PS_SOLID,(width &gt; height) ? width : height,RGB(255,255,255));
	hBrush = CreateSolidBrush(RGB(0,0,0));

	SelectObject(dc,hPen);
	SelectObject(dc,hBrush);
	while ((start + runtime &gt;= now) &amp;&amp; (now &gt;= start))
	{
		sine = 1 + sin((double)tick/(double)1000);

		Rectangle(dc,x+sine*width,
					y+sine*height,
					x+width-sine*width,
					y+height-sine*height);

		now = GetTickCount();
		tick = now - start;
	}
	return 0;
}
</code></pre>
<p>thx.</p>
<p>EDIT: Wie kann ich den Effekt etwas transparenter gestalten?<br />
Probiert ihn doch mal aus. 10 sekunden warten, wenn er zu ende ist, einfach mal die windows-taste drücken.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1334675</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1334675</guid><dc:creator><![CDATA[Script-Styler]]></dc:creator><pubDate>Sun, 29 Jul 2007 23:21:53 GMT</pubDate></item><item><title><![CDATA[Reply to DC Wiederherstellen on Sun, 29 Jul 2007 23:33:24 GMT]]></title><description><![CDATA[<p>Also erstmal vorweg: Ausprobieren werde ich das bestimmt nicht...!</p>
<p>Ob das ein &quot;suppi proggy&quot; ist, ist sicherlich Geschmackssache, zumal dieses auch einige Fehler enthält. Ich will Dich allerdings nicht von Deinem Triumpf-Gefühl abbringen <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="😃"
    /> . 'Aufräumen' kannst Du einfach mit einem Funktionsaufruf von InvalidateRect.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1334679</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1334679</guid><dc:creator><![CDATA[CodeFinder]]></dc:creator><pubDate>Sun, 29 Jul 2007 23:33:24 GMT</pubDate></item><item><title><![CDATA[Reply to DC Wiederherstellen on Sun, 29 Jul 2007 23:36:04 GMT]]></title><description><![CDATA[<p>was enthält das denn für fehler?</p>
<p>danke.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1334681</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1334681</guid><dc:creator><![CDATA[Script-Styler]]></dc:creator><pubDate>Sun, 29 Jul 2007 23:36:04 GMT</pubDate></item><item><title><![CDATA[Reply to DC Wiederherstellen on Sun, 29 Jul 2007 23:39:13 GMT]]></title><description><![CDATA[<p>das funzt net:</p>
<pre><code class="language-cpp">InvalidateRect(GetDesktopWindow(),&amp;rClient,true);
</code></pre>
<p>thx.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1334684</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1334684</guid><dc:creator><![CDATA[Script-Styler]]></dc:creator><pubDate>Sun, 29 Jul 2007 23:39:13 GMT</pubDate></item><item><title><![CDATA[Reply to DC Wiederherstellen on Sun, 29 Jul 2007 23:40:04 GMT]]></title><description><![CDATA[<p>Script-Styler schrieb:</p>
<blockquote>
<p>was enthält das denn für fehler?</p>
</blockquote>
<p>Du musst Deine erstellten GDI-Objekte (nicht zu verwechseln mit Objekten/Instanzen einer Klasse im Sinne der OOP, aber hier ja nicht zutreffend <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="😉"
    /> ) auch wieder freigeben bzw. den alten Inhalt des HDC's wieder herstellen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1334685</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1334685</guid><dc:creator><![CDATA[CodeFinder]]></dc:creator><pubDate>Sun, 29 Jul 2007 23:40:04 GMT</pubDate></item><item><title><![CDATA[Reply to DC Wiederherstellen on Sun, 29 Jul 2007 23:42:23 GMT]]></title><description><![CDATA[<p>Machs mal so:</p>
<pre><code class="language-cpp">InvalidateRect(GetDesktopWindow(), NULL, TRUE);
UpdateWindow(GetDesktopWindow());
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1334686</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1334686</guid><dc:creator><![CDATA[CodeFinder]]></dc:creator><pubDate>Sun, 29 Jul 2007 23:42:23 GMT</pubDate></item><item><title><![CDATA[Reply to DC Wiederherstellen on Mon, 30 Jul 2007 07:15:30 GMT]]></title><description><![CDATA[<p>thx thx!</p>
<p>aber ist es auch möglich, die vierecke etwas (50%) transprent zu zeichnen?</p>
<p>thx.</p>
<p>EDIT:<br />
so das ist jetzt mein feddich-quellcode.<br />
aber irgendwie will er hinterher net aufräumen (desktop).</p>
<pre><code class="language-cpp">#include &lt;windows.h&gt;
#include &lt;math.h&gt;

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
                    LPSTR lpCmdLine, int nCmdShow)
{
	HDC		dc = GetDC(0);
	HBRUSH	hBrush[2];
	RECT	rClient;
	double	sine;

	DWORD	runtime = 10000;
	DWORD	start = GetTickCount();
	DWORD	now = start;
	DWORD	tick = 0;

	GetClientRect(GetDesktopWindow(),&amp;rClient);

	int		x = rClient.left;
	int		y = rClient.top;
	int		width = rClient.right-rClient.left;
	int		height = rClient.bottom-rClient.top;

	hBrush[0] = CreateSolidBrush(RGB(0,0,0));
	hBrush[1] = CreateSolidBrush(RGB(255,0,0));

	while ((start + runtime &gt;= now) &amp;&amp; (now &gt;= start))
	{
		// Make sine
		sine = ((double)1 + (double)cos((double)tick/(double)1000))/(double)2;

		// Draw background
		SelectObject(dc,hBrush[0]);
		Rectangle(dc,x,
					y,
					x+width,
					y+height);

		// Draw foreground
		SelectObject(dc,hBrush[1]);
		Rectangle(dc,x+sine*width,
					y+sine*height,
					x+width-sine*width,
					y+height-sine*height);

		Sleep(1000/25);
		now = GetTickCount();
		tick = now - start;
	}

	// Free GDI-Objects
	for (int i=0;i&lt;2;i++)
	{
		DeleteObject(hBrush[i]);
		hBrush[i] = NULL;
	}

	// Update desktop window
	InvalidateRect(GetDesktopWindow(), NULL, true);
	UpdateWindow(GetDesktopWindow());

	return 0;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1334734</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1334734</guid><dc:creator><![CDATA[Script-Styler]]></dc:creator><pubDate>Mon, 30 Jul 2007 07:15:30 GMT</pubDate></item><item><title><![CDATA[Reply to DC Wiederherstellen on Mon, 30 Jul 2007 09:18:44 GMT]]></title><description><![CDATA[<p>nun,<br />
mir kommt die idee, vor her ein neues DC zu erstellen, den desktop dareinzublitten und dann zum schluss wieder in das haupt dc zurückblitten.<br />
wie realisiere ich das?<br />
thx.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1334798</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1334798</guid><dc:creator><![CDATA[Script-Styler]]></dc:creator><pubDate>Mon, 30 Jul 2007 09:18:44 GMT</pubDate></item><item><title><![CDATA[Reply to DC Wiederherstellen on Mon, 30 Jul 2007 10:12:23 GMT]]></title><description><![CDATA[<p>nene!!!<br />
ich weiß wies geht:</p>
<pre><code class="language-cpp">InvalidateRect(0, NULL, TRUE);
	UpdateWindow(GetDesktopWindow());
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1334833</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1334833</guid><dc:creator><![CDATA[Script-Styler]]></dc:creator><pubDate>Mon, 30 Jul 2007 10:12:23 GMT</pubDate></item><item><title><![CDATA[Reply to DC Wiederherstellen on Mon, 30 Jul 2007 15:41:22 GMT]]></title><description><![CDATA[<p>msdn: DeleteObject schrieb:</p>
<blockquote>
<p>Do not delete a drawing object (pen or brush) while it is still selected into a DC.</p>
</blockquote>
]]></description><link>https://www.c-plusplus.net/forum/post/1335073</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1335073</guid><dc:creator><![CDATA[geeky]]></dc:creator><pubDate>Mon, 30 Jul 2007 15:41:22 GMT</pubDate></item></channel></rss>