<?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[API Animation und Cls()?]]></title><description><![CDATA[<p>Das ist mein Code:</p>
<pre><code class="language-cpp">#include &lt;windows.h&gt;
#include &lt;math.h&gt;
#include &lt;conio.h&gt;
#define NUM      1000
#define TWOPI   (2 * 3.14159)

LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM);

int WINAPI WinMain (HINSTANCE hInstance,
                    HINSTANCE hPrevInstance,
                    PSTR szCmdLine,
                    int iCmdShow)

{
    static TCHAR szAppName[] = TEXT (&quot;Animation&quot;);
    HWND hwnd;               /* This is the handle for our window */
    MSG msg;                 /* Here messages to the application are saved */
    WNDCLASS wndclass;       /* Data structure for the windowclass */

    wndclass.style           =       CS_HREDRAW | CS_VREDRAW;                 
    wndclass.lpfnWndProc     =       WndProc;
    wndclass.cbClsExtra      =       0;
    wndclass.cbWndExtra      =       0;
    wndclass.hInstance       =       hInstance;
    wndclass.hIcon           =       LoadIcon (NULL, IDI_APPLICATION);
    wndclass.hCursor         =       LoadCursor (NULL, IDC_ARROW);
    wndclass.hbrBackground   =       (HBRUSH) GetStockObject (WHITE_BRUSH);
    wndclass.lpszMenuName    =       NULL;
    wndclass.lpszClassName   =       szAppName;
    /* Register the window class, and if it fails quit the program */
    if (!RegisterClass (&amp;wndclass))
    {
        MessageBox (NULL, TEXT (&quot;Dieses Programm setzt ein aktuelles Betriebsystem vorraus!&quot;), szAppName, MB_ICONERROR);
        return 0;
    }
    /* The class is registered, let's create the program*/
    hwnd = CreateWindow (szAppName,                   /* Extended possibilites for variation */
           TEXT (&quot;Animation mit Polyline&quot;),
           WS_OVERLAPPEDWINDOW,
           CW_USEDEFAULT,
           CW_USEDEFAULT,
           CW_USEDEFAULT,
           CW_USEDEFAULT,
           NULL,
           NULL,        
           hInstance,
           NULL); 

    /* Make the window visible on the screen */
    ShowWindow (hwnd, iCmdShow);
    UpdateWindow(hwnd);
    /* Run the message loop. It will run until GetMessage() returns 0 */
    while (GetMessage (&amp;msg, NULL, 0, 0))
    {
        /* Translate virtual-key messages into character messages */
        TranslateMessage(&amp;msg);
        /* Send message to WindowProcedure */
        DispatchMessage(&amp;msg);
    }

    /* The program return-value is 0 - The value that PostQuitMessage() gave */
    return msg.wParam;
}

/*  This function is called by the Windows function DispatchMessage()  */

LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
        static int cxClient, cyClient;
        HDC hdc;
        int i;
        PAINTSTRUCT ps;
        POINT apt[NUM];
        static int cxLinePlot, cyLinePlot;
    switch (message)                  /* handle the messages */
    {
        case WM_SIZE:
             cxClient = LOWORD(lParam);
             cyClient = HIWORD(lParam);
             cxLinePlot = 0;
             cyLinePlot = (HIWORD(lParam)/2);
        case WM_PAINT:

        hdc = BeginPaint(hwnd, &amp;ps);
        for(;;)
        {
                if(cxLinePlot==cxClient)
                {
                                        cxLinePlot = 0;
                }
                cxLinePlot++;
                //horizontaler Mittelstrich
                MoveToEx(hdc, 0, cyLinePlot, NULL);
                LineTo(hdc, cxClient, cyLinePlot);
                //senkrechter Mittelstrich
                MoveToEx(hdc, cxLinePlot, 0, NULL);
                LineTo(hdc, cxLinePlot, cyClient);
                //Quadrat außen Rum
                MoveToEx(hdc, (cxLinePlot - 50), (cyLinePlot - 50), NULL);
                LineTo(hdc, (cxLinePlot + 50), (cyLinePlot - 50));

                MoveToEx(hdc, (cxLinePlot + 50), (cyLinePlot - 50), NULL);
                LineTo(hdc, (cxLinePlot + 50), (cyLinePlot + 50));

                MoveToEx(hdc, (cxLinePlot + 50), (cyLinePlot + 50), NULL);
                LineTo(hdc, (cxLinePlot - 50), (cyLinePlot + 50));

                MoveToEx(hdc, (cxLinePlot - 50), (cyLinePlot + 50), NULL);
                LineTo(hdc, (cxLinePlot - 50), (cyLinePlot - 50));

                //Kreuz
                MoveToEx(hdc, (cxLinePlot - 50), (cyLinePlot - 50), NULL);
                LineTo(hdc, (cxLinePlot + 50), (cyLinePlot + 50));

                MoveToEx(hdc, (cxLinePlot + 50), (cyLinePlot - 50), NULL);
                LineTo(hdc, (cxLinePlot - 50), (cyLinePlot + 50));
                //Zeichnen
                Polyline(hdc, apt, NUM);
                Sleep(1);
        }

            EndPaint (hwnd, &amp;ps);
            return 0;
        case WM_DESTROY:
            PostQuitMessage(0);       /* send a WM_QUIT to the message queue */
            return 0;
    }
    return DefWindowProc(hwnd, message, wParam, lParam);
}
</code></pre>
<p>1. Problem: Während der Animation reagiert das Programm nicht, d. h. ich muss es mit Windows beenden.<br />
2. Problem: Gibt es eine Funktion wie in der Dos - Konsole System(&quot;cls&quot;), die ich da anwenden kann? Man soll ja nicht nur einen schwartzen Bildschirm sehen können.<br />
Vielen dank für die Antworten im Vorraus! <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/topic/132098/api-animation-und-cls</link><generator>RSS for Node</generator><lastBuildDate>Sat, 11 Jul 2026 06:19:40 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/132098.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 08 Jan 2006 12:28:10 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to API Animation und Cls()? on Sun, 08 Jan 2006 12:28:53 GMT]]></title><description><![CDATA[<p>Das ist mein Code:</p>
<pre><code class="language-cpp">#include &lt;windows.h&gt;
#include &lt;math.h&gt;
#include &lt;conio.h&gt;
#define NUM      1000
#define TWOPI   (2 * 3.14159)

LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM);

int WINAPI WinMain (HINSTANCE hInstance,
                    HINSTANCE hPrevInstance,
                    PSTR szCmdLine,
                    int iCmdShow)

{
    static TCHAR szAppName[] = TEXT (&quot;Animation&quot;);
    HWND hwnd;               /* This is the handle for our window */
    MSG msg;                 /* Here messages to the application are saved */
    WNDCLASS wndclass;       /* Data structure for the windowclass */

    wndclass.style           =       CS_HREDRAW | CS_VREDRAW;                 
    wndclass.lpfnWndProc     =       WndProc;
    wndclass.cbClsExtra      =       0;
    wndclass.cbWndExtra      =       0;
    wndclass.hInstance       =       hInstance;
    wndclass.hIcon           =       LoadIcon (NULL, IDI_APPLICATION);
    wndclass.hCursor         =       LoadCursor (NULL, IDC_ARROW);
    wndclass.hbrBackground   =       (HBRUSH) GetStockObject (WHITE_BRUSH);
    wndclass.lpszMenuName    =       NULL;
    wndclass.lpszClassName   =       szAppName;
    /* Register the window class, and if it fails quit the program */
    if (!RegisterClass (&amp;wndclass))
    {
        MessageBox (NULL, TEXT (&quot;Dieses Programm setzt ein aktuelles Betriebsystem vorraus!&quot;), szAppName, MB_ICONERROR);
        return 0;
    }
    /* The class is registered, let's create the program*/
    hwnd = CreateWindow (szAppName,                   /* Extended possibilites for variation */
           TEXT (&quot;Animation mit Polyline&quot;),
           WS_OVERLAPPEDWINDOW,
           CW_USEDEFAULT,
           CW_USEDEFAULT,
           CW_USEDEFAULT,
           CW_USEDEFAULT,
           NULL,
           NULL,        
           hInstance,
           NULL); 

    /* Make the window visible on the screen */
    ShowWindow (hwnd, iCmdShow);
    UpdateWindow(hwnd);
    /* Run the message loop. It will run until GetMessage() returns 0 */
    while (GetMessage (&amp;msg, NULL, 0, 0))
    {
        /* Translate virtual-key messages into character messages */
        TranslateMessage(&amp;msg);
        /* Send message to WindowProcedure */
        DispatchMessage(&amp;msg);
    }

    /* The program return-value is 0 - The value that PostQuitMessage() gave */
    return msg.wParam;
}

/*  This function is called by the Windows function DispatchMessage()  */

LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
        static int cxClient, cyClient;
        HDC hdc;
        int i;
        PAINTSTRUCT ps;
        POINT apt[NUM];
        static int cxLinePlot, cyLinePlot;
    switch (message)                  /* handle the messages */
    {
        case WM_SIZE:
             cxClient = LOWORD(lParam);
             cyClient = HIWORD(lParam);
             cxLinePlot = 0;
             cyLinePlot = (HIWORD(lParam)/2);
        case WM_PAINT:

        hdc = BeginPaint(hwnd, &amp;ps);
        for(;;)
        {
                if(cxLinePlot==cxClient)
                {
                                        cxLinePlot = 0;
                }
                cxLinePlot++;
                //horizontaler Mittelstrich
                MoveToEx(hdc, 0, cyLinePlot, NULL);
                LineTo(hdc, cxClient, cyLinePlot);
                //senkrechter Mittelstrich
                MoveToEx(hdc, cxLinePlot, 0, NULL);
                LineTo(hdc, cxLinePlot, cyClient);
                //Quadrat außen Rum
                MoveToEx(hdc, (cxLinePlot - 50), (cyLinePlot - 50), NULL);
                LineTo(hdc, (cxLinePlot + 50), (cyLinePlot - 50));

                MoveToEx(hdc, (cxLinePlot + 50), (cyLinePlot - 50), NULL);
                LineTo(hdc, (cxLinePlot + 50), (cyLinePlot + 50));

                MoveToEx(hdc, (cxLinePlot + 50), (cyLinePlot + 50), NULL);
                LineTo(hdc, (cxLinePlot - 50), (cyLinePlot + 50));

                MoveToEx(hdc, (cxLinePlot - 50), (cyLinePlot + 50), NULL);
                LineTo(hdc, (cxLinePlot - 50), (cyLinePlot - 50));

                //Kreuz
                MoveToEx(hdc, (cxLinePlot - 50), (cyLinePlot - 50), NULL);
                LineTo(hdc, (cxLinePlot + 50), (cyLinePlot + 50));

                MoveToEx(hdc, (cxLinePlot + 50), (cyLinePlot - 50), NULL);
                LineTo(hdc, (cxLinePlot - 50), (cyLinePlot + 50));
                //Zeichnen
                Polyline(hdc, apt, NUM);
                Sleep(1);
        }

            EndPaint (hwnd, &amp;ps);
            return 0;
        case WM_DESTROY:
            PostQuitMessage(0);       /* send a WM_QUIT to the message queue */
            return 0;
    }
    return DefWindowProc(hwnd, message, wParam, lParam);
}
</code></pre>
<p>1. Problem: Während der Animation reagiert das Programm nicht, d. h. ich muss es mit Windows beenden.<br />
2. Problem: Gibt es eine Funktion wie in der Dos - Konsole System(&quot;cls&quot;), die ich da anwenden kann? Man soll ja nicht nur einen schwartzen Bildschirm sehen können.<br />
Vielen dank für die Antworten im Vorraus! <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/960479</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/960479</guid><dc:creator><![CDATA[IpOperator]]></dc:creator><pubDate>Sun, 08 Jan 2006 12:28:53 GMT</pubDate></item><item><title><![CDATA[Reply to API Animation und Cls()? on Sun, 08 Jan 2006 12:32:49 GMT]]></title><description><![CDATA[<p>Du hast ja auch eine Endlosschleife, was wunderst Du Dich da, dass Dein Programm nicht mehr reagiert?<br />
Windows ist Ereignisorientiert... und wenn Du keine Ereignisse mehr zulässt, dann kann Windows nix dafür...</p>
<p>Bzgl. dem &quot;cls&quot;: Hab ich nicht ganz verstanden... oder meinst Du OnEraseBackground ?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/960483</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/960483</guid><dc:creator><![CDATA[Jochen Kalmbach]]></dc:creator><pubDate>Sun, 08 Jan 2006 12:32:49 GMT</pubDate></item><item><title><![CDATA[Reply to API Animation und Cls()? on Sun, 08 Jan 2006 15:27:33 GMT]]></title><description><![CDATA[<p>Kann man das irgendwie ohne ereignis eine animation erstellen, die nicht in einer endlosschleife abgespielt wird?? (z.B. wie hier mit Sleep(x);)<br />
mit cls meine ich, dass das ganze fenster komplett neu gezeichnet wird, d. h. noch einmal ne schicht weiß drauf, damit das vorherige nicht mehr zu sehen ist, und dann noch einmal eine figur.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/960669</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/960669</guid><dc:creator><![CDATA[IpOperator]]></dc:creator><pubDate>Sun, 08 Jan 2006 15:27:33 GMT</pubDate></item><item><title><![CDATA[Reply to API Animation und Cls()? on Sun, 08 Jan 2006 16:12:45 GMT]]></title><description><![CDATA[<p>WM_PAINT darf nicht hängenbleiben also ist ein</p>
<pre><code>for(;;)
</code></pre>
<p>da nix. aber da der threadtitel api animation lautet, vermute ich dass sich was bewegen soll. am einfachsten, aber dafür auch nur begrenzt tauglich ist folgendes:</p>
<p>das hier kann man zB in die WinMain setzen</p>
<pre><code>// timer initialisieren
  SetTimer(hWnd,             // handle 
    1,                       // id 
    55,                      // 55 millisekunden 
    (TIMERPROC) NULL);       // kein callback
</code></pre>
<p>und das hier in die WndProc</p>
<pre><code>if(message==WM_TIMER)
{
  // es gibt nur einen timer, deshalb ist mir die ID egal
  // offset++; // quasi ein counter für den timer
  InvalidateRect(hWnd,NULL,NULL); // neuzeichnen, dabei nicht löschen
}
</code></pre>
<p>ein google mit InvalidateRect könnte dir auch klarheit über dein fehlendes cls() geben..</p>
<pre><code>InvalidateRect(hWnd,NULL,true);
</code></pre>
<p>das löscht vorher den zeichenbereich.</p>
<p>solange sich nichts bewegt, ist es sinniger, in zB WM_CREATE n bitmap zu zeichnen, das später mit BitBlt nur noch dargestellt wird. doublebuffering benötigst du dann nicht. erst bei animationen wird das wichtig, um flackern zu vermeiden.</p>
<p>du wirst mit api-animation schnell an deine grenzen stossen. aber man lernt bisschen was dabei. SetTimer ist auch nur begrenzt brauchbar, manche sagen das ding tickt nicht richtig ^^</p>
<p>grüsse, die katz .. und hello world ausserdem, ich bin neu im forum <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/960709</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/960709</guid><dc:creator><![CDATA[plapperkatz]]></dc:creator><pubDate>Sun, 08 Jan 2006 16:12:45 GMT</pubDate></item><item><title><![CDATA[Reply to API Animation und Cls()? on Sun, 08 Jan 2006 16:19:13 GMT]]></title><description><![CDATA[<p>auch willkommen <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="😉"
    /><br />
thx, jetzt läufts</p>
]]></description><link>https://www.c-plusplus.net/forum/post/960734</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/960734</guid><dc:creator><![CDATA[IpOperator]]></dc:creator><pubDate>Sun, 08 Jan 2006 16:19:13 GMT</pubDate></item></channel></rss>