<?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[Neuzeichnen verhindern]]></title><description><![CDATA[<p>hallo</p>
<p>ich habe eine funktion in WM_PAINT geschrieben die gezeichnet wird, jedesmal wenn das fenster neu aktiviert wird, beginnt es wieder alles neu zu berechnen und zu zeichnen.<br />
gibt es eine möglichkeit zu verhinder das alles immer neu berechnet werden muss, so dass einfach das schonmal berechnete angezeigt wird?</p>
<p>vielen dank!</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/229636/neuzeichnen-verhindern</link><generator>RSS for Node</generator><lastBuildDate>Fri, 10 Apr 2026 05:37:16 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/229636.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 14 Dec 2008 17:25:16 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Neuzeichnen verhindern on Sun, 14 Dec 2008 17:25:16 GMT]]></title><description><![CDATA[<p>hallo</p>
<p>ich habe eine funktion in WM_PAINT geschrieben die gezeichnet wird, jedesmal wenn das fenster neu aktiviert wird, beginnt es wieder alles neu zu berechnen und zu zeichnen.<br />
gibt es eine möglichkeit zu verhinder das alles immer neu berechnet werden muss, so dass einfach das schonmal berechnete angezeigt wird?</p>
<p>vielen dank!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1630412</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1630412</guid><dc:creator><![CDATA[derfer]]></dc:creator><pubDate>Sun, 14 Dec 2008 17:25:16 GMT</pubDate></item><item><title><![CDATA[Reply to Neuzeichnen verhindern on Sun, 14 Dec 2008 17:31:05 GMT]]></title><description><![CDATA[<p>da musst du halt den Teil, der berechnet werden muss an einem anderen Ort berechnen. Oder du stellst fest, ob es neu berechnet werden muss und nur dann neu berechnest. Ich kenne ja deinen Code nicht daher kann man es nicht genau sagen</p>
<pre><code class="language-cpp">// Pseudocode
if(mussNeuBerechnetWerden)
{
// berechnen
}
// zeichnen
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1630416</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1630416</guid><dc:creator><![CDATA[[[global:guest]]]]></dc:creator><pubDate>Sun, 14 Dec 2008 17:31:05 GMT</pubDate></item><item><title><![CDATA[Reply to Neuzeichnen verhindern on Sun, 14 Dec 2008 17:35:40 GMT]]></title><description><![CDATA[<p>ich habe punkt für die lienien die gezeichnet werden sollen in einem point-array gespeichert, wen ich diese in einer anderen funktion berechnen lasse stürtzt das programm sofort ab!<br />
das passiert auch wenn ich dieses point-array global mache, so dass beim nächsten aufruf von WM_PAINT immernoch die gleichen linien gezeichnet werden</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1630418</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1630418</guid><dc:creator><![CDATA[derfer]]></dc:creator><pubDate>Sun, 14 Dec 2008 17:35:40 GMT</pubDate></item><item><title><![CDATA[Reply to Neuzeichnen verhindern on Sun, 14 Dec 2008 18:19:35 GMT]]></title><description><![CDATA[<p>derfer schrieb:</p>
<blockquote>
<p>wen ich diese in einer anderen funktion berechnen lasse stürtzt das programm sofort ab!<br />
das passiert auch wenn ich dieses point-array global mache</p>
</blockquote>
<p>Zeig doch mal deinen Code</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1630437</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1630437</guid><dc:creator><![CDATA[auf code gugger]]></dc:creator><pubDate>Sun, 14 Dec 2008 18:19:35 GMT</pubDate></item><item><title><![CDATA[Reply to Neuzeichnen verhindern on Mon, 15 Dec 2008 04:00:35 GMT]]></title><description><![CDATA[<p>@auf code gugger:<br />
wollte ich auch gerade sagen <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>
<p>Es ist kein Problem ein Array vorher zu befüllen und dann zu Zeichnen.</p>
<p>Hier wird als Beispiel ein 2D array befüllt und dann gezeichnet, dabei bediene ich mich eines Timers: (aus Coneway's Life)</p>
<pre><code class="language-cpp">case WM_TIMER:
      {
 //calulating next_generation
         bool next_gen[width][height];
         bool area[3][3];
         //first the four corners

         //0,0 corner
               //mid of area has to be set false
               area[1][1]=false;
               //right bottom
               area[0][0]=field[width-1][height-1];
               //left bottom
               area[1][0]=field[0][height-1];
               area[2][0]=field[1][height-1];
               //right top
               area[0][1]=field[width-1][0];
               area[0][2]=field[width-1][1];
               //rest
               area[2][1]=field[1][0];
               area[1][2]=field[0][1];
               area[2][2]=field[1][1];
         next_gen[0][0]=deadORalive(field[0][0],area);
         //width,0 corner
               //mid of area has to be set false
               area[1][1]=false;
               //right bottom
               area[0][0]=field[width-2][height-1];
               area[1][0]=field[width-1][height-1];
               //left bottom
               area[0][2]=field[0][height-1];
               //left top
               area[1][2]=field[0][0];
               area[2][2]=field[0][1];
               //rest
               area[0][1]=field[width-2][0];
               area[0][2]=field[width-2][1];
               area[1][2]=field[width-1][1];
         next_gen[width-1][0]=deadORalive(field[width-1][0],area);
         //width,height corner
               //mid of area has to be set false
               area[1][1]=false;
               //left bottom
               area[2][0]=field[0][height-2];
               area[2][1]=field[0][height-1];
               //left top
               area[2][2]=field[0][0];
               //right top
               area[1][2]=field[width-1][0];
               area[0][2]=field[width-2][0];
               //rest
               area[0][0]=field[width-2][height-2];
               area[1][0]=field[width-1][height-2];
               area[0][1]=field[width-2][height-1];
         next_gen[width-1][height-1]=deadORalive(field[width-1][height-1],area);
         //0,height corner
               //mid of area has to be set false
               area[1][1]=false;
               //right top
               area[0][2]=field[width-1][0];
               //right bottom
               area[0][0]=field[width-1][height-2];
               area[0][1]=field[width-1][height-1];
               //left top
               area[1][2]=field[0][0];
               area[2][2]=field[0][1];
               //rest
               area[1][0]=field[0][height-2];
               area[2][0]=field[1][height-2];
               area[2][1]=field[1][height-1];
         next_gen[0][height-1]=deadORalive(field[0][height-1],area);

         //H line
         area[1][1]=false;       
         for(int i=1;i&lt;(width-1);i++)
         { 
          //calculating rest of top line
          //bottom
          area[0][0]=field[i-1][height-1];
          area[1][0]=field[i][height-1];
          area[2][0]=field[i+1][height-1];
          //rest
          area[0][1]=field[i-1][0];
          area[0][2]=field[i-1][1];
          area[2][1]=field[i+1][0];
          area[2][2]=field[i+1][1];
          area[1][2]=field[i][1];
         next_gen[i][0]=deadORalive(field[i][0],area);

         //calculating for bottom line
         //top
          area[0][2]=field[i-1][0];
          area[1][2]=field[i][0];
          area[2][2]=field[i+1][0];
          //rest                    
          area[0][0]=field[i-1][height-2];
          area[0][1]=field[i-1][height-1];
          area[1][0]=field[i][height-2];
          area[2][0]=field[i+1][height-2];
          area[2][1]=field[i+1][height-1];

         next_gen[i][height-1]=deadORalive(field[i][height-1],area);
         }
         //V line
         area[1][1]=false;       
         for(int i=1;i&lt;(height-1);i++)
         { //calculating rest of left line
           //left
           area[0][0]=field[width-1][i-1];
           area[0][1]=field[width-1][i];
           area[0][2]=field[width-1][i+1];
           //rest
           area[1][0]=field[0][i-1];
           area[2][0]=field[1][i-1];
           area[2][1]=field[1][i];
           area[1][2]=field[0][i+1];
           area[2][2]=field[1][i+1];
         next_gen[0][i]=deadORalive(field[0][i],area);  
          //calulating rest of right line
          //right
          area[2][0]=field[0][i-1];
          area[2][1]=field[0][i];
          area[2][2]=field[0][i+1];
          //rest
          area[0][0]=field[width-2][i-1];
          area[0][1]=field[width-2][i];
          area[0][2]=field[width-2][i+1];
          area[1][0]=field[width-1][i-1];
          area[1][2]=field[width-1][i+1];
         next_gen[width-1][i]=deadORalive(field[width-1][i],area);   
         }
         //calculating rest of next_gen field
         area[1][1]=false;
         for(int i=1;i&lt;(width-1);i++)
         {for(int j=1;j&lt;(height-1);j++)
         {
         area[0][0]=field[i-1][j-1];
         area[0][1]=field[i-1][j];
         area[0][2]=field[i-1][j+1];
         area[2][0]=field[i+1][j-1];
         area[2][1]=field[i+1][j];
         area[2][2]=field[i+1][j+1];
         area[1][0]=field[i][j-1];
         area[1][2]=field[i][j+1];
         next_gen[i][j]=deadORalive(field[i][j],area);        
         }}
         //copy to actually field;
         for(int i=0;i&lt;width;i++)
         for(int j=0;j&lt;height;j++)
         {field[i][j]=next_gen[i][j];};
         InvalidateRect(hwnd, NULL, FALSE);
         return 0;
      }

         case WM_ERASEBKGND: {return 1;}
</code></pre>
<p>das field array ist als static int array innerhalb der callback fkt angelegt, kann aber auch global sein.<br />
Das zeichnen läuft dann per double puffer:</p>
<pre><code class="language-cpp">case WM_PAINT:
        {

         PAINTSTRUCT ps;
         HDC hDC=BeginPaint(hwnd,&amp;ps);
         int bkgCol=0;//0x00d8e9ec;
         int frmCol=0x00b99d7f;
         HDC hMemDC=CreateCompatibleDC(hDC);
         HBITMAP hBm = CreateCompatibleBitmap(hDC, width, height); 
         SelectObject(hMemDC, hBm); 
         //SetBkColor(hMemDC,bkgCol);

         for(int i=0;i&lt;width;i++){
         for(int j=0;j&lt;height;j++){
               if(field[i][j]==true)
               {SetPixel(hMemDC,i,j,frmCol);}
               else{SetPixel(hMemDC,i,j,bkgCol);};
         }}                         

       BitBlt(hDC, 0, 0, width, height, hMemDC, 0, 0, SRCCOPY); 
       DeleteDC(hMemDC);
       DeleteObject(hBm);  
       EndPaint(hwnd,&amp;ps);

        return 0;
        }
</code></pre>
<p>Ich hoffe das das Beispiel hilfreich ist, denkt an das (c) muhahaha <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>greetz</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1630584</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1630584</guid><dc:creator><![CDATA[zeusosc]]></dc:creator><pubDate>Mon, 15 Dec 2008 04:00:35 GMT</pubDate></item><item><title><![CDATA[Reply to Neuzeichnen verhindern on Mon, 15 Dec 2008 07:31:03 GMT]]></title><description><![CDATA[<p>Ich sehe kein Problem.<br />
width, height sind Konstanten wie ich sehe.</p>
<p>Wo kracht es denn.<br />
Der Debugger sollte Dir doch helfen, wenn Du Dir die Variablen und die Lokation des Crash ansiehst.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1630604</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1630604</guid><dc:creator><![CDATA[Martin Richter]]></dc:creator><pubDate>Mon, 15 Dec 2008 07:31:03 GMT</pubDate></item><item><title><![CDATA[Reply to Neuzeichnen verhindern on Mon, 15 Dec 2008 08:25:56 GMT]]></title><description><![CDATA[<p><a class="plugin-mentions-user plugin-mentions-a" href="https://www.c-plusplus.net/forum/uid/35992">@Martin</a>: derfer ist der Thread opener,.. ich habe nur ein beispiel wie es funktioniert gegeben,...<br />
greetz</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1630625</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1630625</guid><dc:creator><![CDATA[zeusosc]]></dc:creator><pubDate>Mon, 15 Dec 2008 08:25:56 GMT</pubDate></item><item><title><![CDATA[Reply to Neuzeichnen verhindern on Mon, 15 Dec 2008 08:54:42 GMT]]></title><description><![CDATA[<p>zeusosc schrieb:</p>
<blockquote>
<p><a class="plugin-mentions-user plugin-mentions-a" href="https://www.c-plusplus.net/forum/uid/35992">@Martin</a>: derfer ist der Thread opener,.. ich habe nur ein beispiel wie es funktioniert gegeben,...<br />
greetz</p>
</blockquote>
<p>Upps! Sorry, das habe ich übersehen! <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/1630634</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1630634</guid><dc:creator><![CDATA[Martin Richter]]></dc:creator><pubDate>Mon, 15 Dec 2008 08:54:42 GMT</pubDate></item></channel></rss>