<?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[Frage zu WM_TIMER]]></title><description><![CDATA[<p>Hi.</p>
<p>Ich suche einen Weg, eine WM_PAINT Message ein Mal pro Sekunde zu aktualisieren und bin dabei auf die Timer-funktionen gestossen. So richtig will die Sache allerdings nicht funktionieren, also die Updates finden nicht statt.</p>
<pre><code class="language-cpp">LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{   
    switch (message)                
    {
        static int nWidth,nHeight;

        case WM_CREATE:
          int res;     
          res = SetTimer(hwnd, 1, 1000, NULL);
          if(res == 0) MessageBox(hwnd, &quot;Could not SetTimer()!&quot;, &quot;Error&quot;, MB_OK | MB_ICONEXCLAMATION);
          return 0;
        break;

        case WM_TIMER:
          UpdateWindow(hwnd);
        return 0;

        case WM_PAINT:
          HDC     hDC;
          PAINTSTRUCT ps;
          hDC = BeginPaint(hwnd, &amp;ps);

          //Funktion Plot aufrufen
          if (nWidth&lt;=nHeight)
          { 
            Plot(hDC,(int)(nWidth/2.-30.),(int)(nWidth/2.),int (nHeight/2.));
          }
          else
          { 
            Plot(hDC,(int)(nHeight/2.-30.),(int)(nWidth/2.),int (nHeight/2.));
          }
          EndPaint(hwnd, &amp;ps);
        return 0;

        case WM_DESTROY:
            PostQuitMessage (0);      
        break;

        case WM_SIZE:
         nWidth = LOWORD(lParam);  // width of client area
         nHeight = HIWORD(lParam); // height of client area
         InvalidateRect(hwnd,NULL,1);
         UpdateWindow(hwnd); //Fenster updaten
        break;    

        default:                      /* for messages that we don't deal with */
            return DefWindowProc (hwnd, message, wParam, lParam);
    }

    return 0;
}
</code></pre>
<p>So wie ich es im obenstehenden Quelltext gemacht habe, funzt es nicht. Hat jemand einen Tipp?</p>
<p>Thx, Patric.</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/104509/frage-zu-wm_timer</link><generator>RSS for Node</generator><lastBuildDate>Sat, 02 May 2026 03:16:03 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/104509.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 20 Mar 2005 15:43:22 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Frage zu WM_TIMER on Sun, 20 Mar 2005 15:43:22 GMT]]></title><description><![CDATA[<p>Hi.</p>
<p>Ich suche einen Weg, eine WM_PAINT Message ein Mal pro Sekunde zu aktualisieren und bin dabei auf die Timer-funktionen gestossen. So richtig will die Sache allerdings nicht funktionieren, also die Updates finden nicht statt.</p>
<pre><code class="language-cpp">LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{   
    switch (message)                
    {
        static int nWidth,nHeight;

        case WM_CREATE:
          int res;     
          res = SetTimer(hwnd, 1, 1000, NULL);
          if(res == 0) MessageBox(hwnd, &quot;Could not SetTimer()!&quot;, &quot;Error&quot;, MB_OK | MB_ICONEXCLAMATION);
          return 0;
        break;

        case WM_TIMER:
          UpdateWindow(hwnd);
        return 0;

        case WM_PAINT:
          HDC     hDC;
          PAINTSTRUCT ps;
          hDC = BeginPaint(hwnd, &amp;ps);

          //Funktion Plot aufrufen
          if (nWidth&lt;=nHeight)
          { 
            Plot(hDC,(int)(nWidth/2.-30.),(int)(nWidth/2.),int (nHeight/2.));
          }
          else
          { 
            Plot(hDC,(int)(nHeight/2.-30.),(int)(nWidth/2.),int (nHeight/2.));
          }
          EndPaint(hwnd, &amp;ps);
        return 0;

        case WM_DESTROY:
            PostQuitMessage (0);      
        break;

        case WM_SIZE:
         nWidth = LOWORD(lParam);  // width of client area
         nHeight = HIWORD(lParam); // height of client area
         InvalidateRect(hwnd,NULL,1);
         UpdateWindow(hwnd); //Fenster updaten
        break;    

        default:                      /* for messages that we don't deal with */
            return DefWindowProc (hwnd, message, wParam, lParam);
    }

    return 0;
}
</code></pre>
<p>So wie ich es im obenstehenden Quelltext gemacht habe, funzt es nicht. Hat jemand einen Tipp?</p>
<p>Thx, Patric.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/748925</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/748925</guid><dc:creator><![CDATA[Patrique]]></dc:creator><pubDate>Sun, 20 Mar 2005 15:43:22 GMT</pubDate></item><item><title><![CDATA[Reply to Frage zu WM_TIMER on Sun, 20 Mar 2005 15:48:22 GMT]]></title><description><![CDATA[<p>Tausch das UpdateWindow mal gegen InvalidateRect aus.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/748926</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/748926</guid><dc:creator><![CDATA[Grober]]></dc:creator><pubDate>Sun, 20 Mar 2005 15:48:22 GMT</pubDate></item><item><title><![CDATA[Reply to Frage zu WM_TIMER on Sun, 20 Mar 2005 15:47:38 GMT]]></title><description><![CDATA[<p>Supi!<br />
Danke fuer die schnelle Antwort, es hat funktioniert.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/748927</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/748927</guid><dc:creator><![CDATA[Patrique]]></dc:creator><pubDate>Sun, 20 Mar 2005 15:47:38 GMT</pubDate></item><item><title><![CDATA[Reply to Frage zu WM_TIMER on Sun, 20 Mar 2005 15:51:08 GMT]]></title><description><![CDATA[<p>Grober schrieb:</p>
<blockquote>
<p>Außerdem änderst du in WM_TIMER ja gar keine Variablen.</p>
</blockquote>
<p>Das passiert dann in der PLOT-Funktion. Dort hole ich mir immer die aktuelle Uhrzeit.<br />
Bin dabei c(++) zu ueben und versuch mich gerade an einer (wirklich einfachen) Zeigeruhr.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/748928</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/748928</guid><dc:creator><![CDATA[Patrique]]></dc:creator><pubDate>Sun, 20 Mar 2005 15:51:08 GMT</pubDate></item></channel></rss>