<?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[GDI Problem --&amp;gt; InvalidateRect]]></title><description><![CDATA[<p>Hallo Leute</p>
<p>Zur Zeit programmiere ich gerade einen kleinen Timer. Die Zeit wird dabei im digitalen Format als t-Segment Tiffern ins Anwendungsfenster gezeichnet. Die einzelnen segmente werden mit der GDI-Funktion Polygon gezeichnet. Ich habe ein timer, welcher jede Sekunde einw WM_TIMER Message auslöst.<br />
Am Anfang habe ich einfach jede Sekunde das gesamte Fenster mit der Funktion InvalidateRect ungültig gemacht. Der dritte Parameter dieser Funktion habe ich TRUE gesetzt, also wurde der Background immer gelöscht und neu gezeichnet. So funtionierte eigentlich alles mit einer kleinen Unschönheit, nämlich die, das die Fensterausgabe flackerte, da ich ja immer die hanze Zeit neu gezeichnet habe.<br />
Um diese Problem zu beheben habe ich eine Logik entwickelt, welche nur die Segmente löscht welche ich nicht mehr brauche und die Segmente zeichnet, welche neu gebraucht werden. Jetzt darf ich aber ja der Hintergrund nicht einfach löschen, weil sonst die alte Zeit ja auch gelöst wird, also habe ich den dritten Parameter der Funktion InvalidateRect auf False gesetzt, damit das nicht passiert. Nun das funktionier jetzt eigentlich ganz gut.<br />
ABER: Ich habe jetzt das Problem, dass wenn meine Anwendung im Hintergrund war oder von einem anderen Fenster ganz oder teilweise ünerlagert wurde, dass dann diese Region jeweils meine Zeit nacher gelöst ist. Daselbe passiert auch, wenn ein Menu meiner eigenen Anwendung aufgerufen wird. Das kann ich natürlich nicht so auf sich belassen, wie ihr sicher verstehen könnt.</p>
<p>mfg</p>
<p>Sputnik</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/190161/gdi-problem-gt-invalidaterect</link><generator>RSS for Node</generator><lastBuildDate>Thu, 02 Jul 2026 02:11:09 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/190161.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 20 Aug 2007 10:47:47 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to GDI Problem --&amp;gt; InvalidateRect on Mon, 20 Aug 2007 10:47:47 GMT]]></title><description><![CDATA[<p>Hallo Leute</p>
<p>Zur Zeit programmiere ich gerade einen kleinen Timer. Die Zeit wird dabei im digitalen Format als t-Segment Tiffern ins Anwendungsfenster gezeichnet. Die einzelnen segmente werden mit der GDI-Funktion Polygon gezeichnet. Ich habe ein timer, welcher jede Sekunde einw WM_TIMER Message auslöst.<br />
Am Anfang habe ich einfach jede Sekunde das gesamte Fenster mit der Funktion InvalidateRect ungültig gemacht. Der dritte Parameter dieser Funktion habe ich TRUE gesetzt, also wurde der Background immer gelöscht und neu gezeichnet. So funtionierte eigentlich alles mit einer kleinen Unschönheit, nämlich die, das die Fensterausgabe flackerte, da ich ja immer die hanze Zeit neu gezeichnet habe.<br />
Um diese Problem zu beheben habe ich eine Logik entwickelt, welche nur die Segmente löscht welche ich nicht mehr brauche und die Segmente zeichnet, welche neu gebraucht werden. Jetzt darf ich aber ja der Hintergrund nicht einfach löschen, weil sonst die alte Zeit ja auch gelöst wird, also habe ich den dritten Parameter der Funktion InvalidateRect auf False gesetzt, damit das nicht passiert. Nun das funktionier jetzt eigentlich ganz gut.<br />
ABER: Ich habe jetzt das Problem, dass wenn meine Anwendung im Hintergrund war oder von einem anderen Fenster ganz oder teilweise ünerlagert wurde, dass dann diese Region jeweils meine Zeit nacher gelöst ist. Daselbe passiert auch, wenn ein Menu meiner eigenen Anwendung aufgerufen wird. Das kann ich natürlich nicht so auf sich belassen, wie ihr sicher verstehen könnt.</p>
<p>mfg</p>
<p>Sputnik</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1348080</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1348080</guid><dc:creator><![CDATA[Sputnik]]></dc:creator><pubDate>Mon, 20 Aug 2007 10:47:47 GMT</pubDate></item><item><title><![CDATA[Reply to GDI Problem --&amp;gt; InvalidateRect on Mon, 20 Aug 2007 11:23:10 GMT]]></title><description><![CDATA[<p>Du setzt InvalidateRect wieder auf TRUE und gibst bei WM_ERASEBKND return 0; zurück.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1348121</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1348121</guid><dc:creator><![CDATA[Elektronix]]></dc:creator><pubDate>Mon, 20 Aug 2007 11:23:10 GMT</pubDate></item><item><title><![CDATA[Reply to GDI Problem --&amp;gt; InvalidateRect on Mon, 20 Aug 2007 11:31:59 GMT]]></title><description><![CDATA[<p>oder nimm einfach nen BackBuffer <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=";D"
      alt="😉"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1348131</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1348131</guid><dc:creator><![CDATA[geeky]]></dc:creator><pubDate>Mon, 20 Aug 2007 11:31:59 GMT</pubDate></item><item><title><![CDATA[Reply to GDI Problem --&amp;gt; InvalidateRect on Mon, 20 Aug 2007 13:13:39 GMT]]></title><description><![CDATA[<p>Vielen Dank. Ich werde mal diesen Beiden Varianten nachgehen und dann posten, was sich so ergeben hat.</p>
<p>mfg</p>
<p>Sputnik</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1348257</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1348257</guid><dc:creator><![CDATA[Sputnik]]></dc:creator><pubDate>Mon, 20 Aug 2007 13:13:39 GMT</pubDate></item><item><title><![CDATA[Reply to GDI Problem --&amp;gt; InvalidateRect on Mon, 20 Aug 2007 13:24:19 GMT]]></title><description><![CDATA[<p>also zum Backbuffer, oder auch Doublebuffer hab ich in nem anderen Thread mal was feines verfasst.<br />
da ich jetzt nicht alles nochmal schreiben will, hier der Link:<br />
<a href="http://www.c-plusplus.net/forum/viewtopic-var-t-is-189381-and-highlight-is-.html" rel="nofollow">http://www.c-plusplus.net/forum/viewtopic-var-t-is-189381-and-highlight-is-.html</a></p>
<p>vielleicht hilfts dir ja</p>
<p>MfG DrakoXP</p>
<p>PS.: das ganze funzt auch, wenn man bei InvalidateRect nur einen Teil des Fensters angibt.<br />
dann wird eben auch nur dieses Rechteck neugezeichnet.<br />
alles natürlich Flackerfrei <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/1348265</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1348265</guid><dc:creator><![CDATA[DrakoXP]]></dc:creator><pubDate>Mon, 20 Aug 2007 13:24:19 GMT</pubDate></item><item><title><![CDATA[Reply to GDI Problem --&amp;gt; InvalidateRect on Mon, 20 Aug 2007 14:02:46 GMT]]></title><description><![CDATA[<p>Hmm, ich wollte mal die Möglichkeit mit dem Buffering ausprobieren, aber leider hatte ich nicht so richtig erfolg dabei. Jetzt wird gar nix mer gezeichnet, ausser dem Hintergrund. Das heisst, es werden überhaupt keine grünen Digits mehr gezeichnet.</p>
<p>Hier mein Listing der WM_PAINT:</p>
<pre><code class="language-cpp">case WM_PAINT:
    /* create a devise context */
    hDC = BeginPaint(hWnd, &amp;ps);

    /* set the mapping mode as defined from the menu */
    if(bIsotropic)
        /* set the mapping mode to isotropic */
        SetMapMode(hDC, MM_ISOTROPIC);
    else
        /* set the mapping mode to anisotropic */
        SetMapMode(hDC, MM_ANISOTROPIC);

    /* set the logical coordinate system of the window */
    SetWindowExtEx(hDC, 276, 72, NULL);
    SetViewportExtEx(hDC, iCXClient, iCYClient, NULL);

    /* set the origin of the coordinate system in the window */
    SetWindowOrgEx(hDC, 138, 36, NULL);
    /* set the origin of the coordinate system in the viewport */
    SetViewportOrgEx(hDC, iCXClient / 2, iCYClient / 2, NULL);

    /* load the pen to the devise context */
    SelectObject(hDC, GetStockObject(NULL_PEN));
    /* load the brush for digits to the devise contex */
    SelectObject(hDC, GetHandleToBrush(rgbDigits));

    /* create a buffer for the window outbut */
    HDC hDC2 = CreateCompatibleDC(hDC);
    HBITMAP hBM = CreateCompatibleBitmap(hDC, iCXClient, iCYClient);

    SelectObject(hDC2, hBM);

    /* print the time */
    if(bRedrawAll)
    {
        /* print the time complete new */
        DPrintFullTime(hDC2);
        bRedrawAll = FALSE;
    }
    else
    {
        /* print only the digits who has changed */
        DPrintFragTime(hDC2);
    }

    /* load the buffer to the window outbut */
    BitBlt(hDC, 0, 0, iCXClient, iCYClient, hDC2, 0, 0, SRCCOPY);

    /* cleaning up the objects */
    DeleteObject(hBM);          /* delet the bitmap buffer */
    DeleteDC(hDC2);             /* delet the devise context buffer */

    /* end painting and release the devise context */
    EndPaint(hWnd, &amp;ps);
return(0);
</code></pre>
<p>Kann mir jemand sagen, an was das liegt?</p>
<p>mfg</p>
<p>Sputnik</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1348329</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1348329</guid><dc:creator><![CDATA[Sputnik]]></dc:creator><pubDate>Mon, 20 Aug 2007 14:02:46 GMT</pubDate></item><item><title><![CDATA[Reply to GDI Problem --&amp;gt; InvalidateRect on Mon, 20 Aug 2007 14:21:21 GMT]]></title><description><![CDATA[<p>looool, devise - outbut und diesen Fehler ständig, göul ^^</p>
<p>wie erzwingst du den das WM_PAINT jede Sekunde ?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1348346</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1348346</guid><dc:creator><![CDATA[orr lol]]></dc:creator><pubDate>Mon, 20 Aug 2007 14:21:21 GMT</pubDate></item><item><title><![CDATA[Reply to GDI Problem --&amp;gt; InvalidateRect on Mon, 20 Aug 2007 14:53:38 GMT]]></title><description><![CDATA[<p>Ich starte am Anfang ein Timer, welcher mir jede Sekunde ein WM_TIMER schickt, in wechler ich dann mit der Funktion InvalidateRect das das gesamte Fenster ungültig mache.</p>
<p>Was ist mit der devise und output? Sich nur darüber lustig zu machen bringt mir nichts.</p>
<p>mfg</p>
<p>Sputnik</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1348375</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1348375</guid><dc:creator><![CDATA[Sputnik]]></dc:creator><pubDate>Mon, 20 Aug 2007 14:53:38 GMT</pubDate></item><item><title><![CDATA[Reply to GDI Problem --&amp;gt; InvalidateRect on Mon, 20 Aug 2007 14:53:09 GMT]]></title><description><![CDATA[<p>die Schreibweise, es schreibt sich: devi<strong>c</strong>e</p>
<p>Ich wollte wissen, wie du die WM_PAINT Message erzwingst?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1348379</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1348379</guid><dc:creator><![CDATA[orr lol]]></dc:creator><pubDate>Mon, 20 Aug 2007 14:53:09 GMT</pubDate></item><item><title><![CDATA[Reply to GDI Problem --&amp;gt; InvalidateRect on Mon, 20 Aug 2007 15:13:46 GMT]]></title><description><![CDATA[<p>Du musst Deine Modifikationen (SetWindowOrgEx, SetMapMode, etc) auch für den BackBuffer durchführen.</p>
<p>BTW:<br />
delet -&gt; to delet<strong>e</strong><br />
devise -&gt; devi<strong>c</strong>e<br />
outbut -&gt; out<strong>p</strong>ut<br />
<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>
<p>PS: Da fehlt ein SelectObject am Ende. Du musst den ehemaligen Inhalt des BackBuffer-DC's auch wiederherstellen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1348394</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1348394</guid><dc:creator><![CDATA[CodeFinder]]></dc:creator><pubDate>Mon, 20 Aug 2007 15:13:46 GMT</pubDate></item><item><title><![CDATA[Reply to GDI Problem --&amp;gt; InvalidateRect on Mon, 20 Aug 2007 23:08:40 GMT]]></title><description><![CDATA[<p><a class="plugin-mentions-user plugin-mentions-a" href="https://www.c-plusplus.net/forum/uid/12048">@CodeFinder</a>:<br />
Ich verstehe nicht so ganz, was muss ich wie wieder herstellen?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1348598</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1348598</guid><dc:creator><![CDATA[Sputnik]]></dc:creator><pubDate>Mon, 20 Aug 2007 23:08:40 GMT</pubDate></item><item><title><![CDATA[Reply to GDI Problem --&amp;gt; InvalidateRect on Tue, 21 Aug 2007 11:16:17 GMT]]></title><description><![CDATA[<p>hast du dir eig mal meinen Post angeguckt?</p>
<p>im Gegensatz zu deiner Version funzt meins nähmlich <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f44d.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--thumbs_up"
      title=":+1:"
      alt="👍"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1348890</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1348890</guid><dc:creator><![CDATA[DrakoXP]]></dc:creator><pubDate>Tue, 21 Aug 2007 11:16:17 GMT</pubDate></item><item><title><![CDATA[Reply to GDI Problem --&amp;gt; InvalidateRect on Tue, 21 Aug 2007 12:16:18 GMT]]></title><description><![CDATA[<p><a class="plugin-mentions-user plugin-mentions-a" href="https://www.c-plusplus.net/forum/uid/10459">@DrakoXP</a><br />
Ich habe mir dein Post mal angeschaut, aber ich finde das ein wenig aufwendig für mein Problem.</p>
<p>@all<br />
Mein Problem ist ja nicht das Flackern, das habe ich ja behoben. Mein Problem ist, dass mein Fenster-Inhalt nicht wiederhergestellt wird, wenn mein Fenster von einem Anderen Fenster überlager wurde. Ich denke nicht, dass ich da ein BackBuffer brauche, sondern ich will einfach, dass es wieder hergestellt wird. Das ist also mein eigentliches Problem.</p>
<p>mfg</p>
<p>Sputnik</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1348947</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1348947</guid><dc:creator><![CDATA[Sputnik]]></dc:creator><pubDate>Tue, 21 Aug 2007 12:16:18 GMT</pubDate></item><item><title><![CDATA[Reply to GDI Problem --&amp;gt; InvalidateRect on Tue, 21 Aug 2007 14:19:21 GMT]]></title><description><![CDATA[<p>Als ich noch WinAPI-Nutzer war hab ich den Backbuffer nur bei Programmstart und bei Änderung der Fenstergröße neu angelegt (Du machst das zur Zeit bei jedem WM_PAINT?) - Vor allem das Erzeugen der Backbuffer-Bitmap kann je nach Fenstergröße sonst zum Flaschenhals werden.<br />
Abgesehen davon bleibt dir dann bis zu einem Resize alles vorher gezeichnete erhalten.</p>
<p>Wenn du das auslagerst kannst du dir das DPrintFragTime() vermutlich sparen, es sei denn es ist aus Geschwindigkeitsgründen nötig <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=";D"
      alt="😉"
    /></p>
<p>Ab WinXP bietet Windows auch WS_EX_COMPOSITED an:</p>
<p>msdn - CreateWindowEx schrieb:</p>
<blockquote>
<p>WS_EX_COMPOSITED<br />
Windows XP: Paints all descendants of a window in bottom-to-top painting order using double-buffering. For more information, see Remarks. This cannot be used if the window has a class style of either CS_OWNDC or CS_CLASSDC.</p>
</blockquote>
]]></description><link>https://www.c-plusplus.net/forum/post/1349096</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1349096</guid><dc:creator><![CDATA[geeky]]></dc:creator><pubDate>Tue, 21 Aug 2007 14:19:21 GMT</pubDate></item><item><title><![CDATA[Reply to GDI Problem --&amp;gt; InvalidateRect on Tue, 21 Aug 2007 19:47:51 GMT]]></title><description><![CDATA[<p>Sputnik schrieb:</p>
<blockquote>
<p><a class="plugin-mentions-user plugin-mentions-a" href="https://www.c-plusplus.net/forum/uid/12048">@CodeFinder</a>:<br />
Ich verstehe nicht so ganz, was muss ich wie wieder herstellen?</p>
</blockquote>
<p>Beispiel:</p>
<pre><code class="language-cpp">HBITMAP hbmpOldBits = reinterpret_cast&lt;HBITMAP&gt;(SelectObject(hdcBackBuffer, CreateCompatibleBitmap(...)));
// ... hier mit hdcBackBuffer arbeiten ...
DeleteObject(SelectObject(hdcBackBuffer, hbmpOldBits);
DeleteDC(hdcBackBuffer);
</code></pre>
<p><img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f44d.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--thumbs_up"
      title=":+1:"
      alt="👍"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1349298</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1349298</guid><dc:creator><![CDATA[CodeFinder]]></dc:creator><pubDate>Tue, 21 Aug 2007 19:47:51 GMT</pubDate></item></channel></rss>