<?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[Warum zeichnet sich das Fenster nicht neu???]]></title><description><![CDATA[<p>Hallo zusammen,</p>
<p>habe es mitlerweile geschaft ein Fenster auf den Bildschirm zu zaubern<br />
welches sich in der groesse nicht veraendern laesst und nur ein X zum<br />
schliessen aufweist.<br />
Hatte mich in letzter Zeit hier mal nach dem Thema Timer erkundigt und<br />
das auch soweit hinbekommen. Getestet mit der MessageBox. <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>Nun mein Problem:<br />
Ich habe hier des oefteren gelesen das</p>
<pre><code class="language-cpp">InvalidateRect(hwnd, NULL, TRUE);
</code></pre>
<p>ein Fenster neu zeichnet, oder zumindestens dafuer sorgt das die WM_PAINT<br />
Message an das Fenster geschickt wird.</p>
<p>Im folgenden Code sollte sich der angezeigte Text sekuendlich von A nach B und<br />
dann nach C aendern und dann wieder von vorn anfangen.<br />
Tut er aber nicht, sondern es steht immer nur das A da! <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f621.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--pouting_face"
      title=":rage:"
      alt="😡"
    /></p>
<p>Jemand eine Idee??? <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f615.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--confused_face"
      title=":confused:"
      alt="😕"
    /></p>
<pre><code class="language-cpp">#include &lt;windows.h&gt;

/*  Declare Windows procedure  */
LRESULT CALLBACK WindowProcedure (HWND, UINT, WPARAM, LPARAM);

/*  Make the class name into a global variable  */
char szClassName[ ] = &quot;WindowsApp&quot;;

int WINAPI
WinMain (HINSTANCE hThisInstance,
         HINSTANCE hPrevInstance,
         LPSTR lpszArgument,
         int nFunsterStil)

{
    HWND hwnd;               /* This is the handle for our window */
    MSG messages;            /* Here messages to the application are saved */
    WNDCLASSEX wincl;        /* Data structure for the windowclass */

    /* The Window structure */
    wincl.hInstance = hThisInstance;
    wincl.lpszClassName = szClassName;
    wincl.lpfnWndProc = WindowProcedure;      /* This function is called by windows */
    wincl.style = CS_DBLCLKS | CS_HREDRAW | CS_VREDRAW;   /* Catch double-clicks */
    wincl.cbSize = sizeof (WNDCLASSEX);

    /* Use default icon and mouse-pointer */
    wincl.hIcon = LoadIcon (NULL, IDI_APPLICATION);
    wincl.hIconSm = LoadIcon (NULL, IDI_APPLICATION);
    wincl.hCursor = LoadCursor (NULL, IDC_ARROW);
    wincl.lpszMenuName = NULL;                 /* No menu */
    wincl.cbClsExtra = 0;                      /* No extra bytes after the window class */
    wincl.cbWndExtra = 0;                      /* structure or the window instance */
    /* Use actual Windows's color as the background of the window */
    wincl.hbrBackground = (HBRUSH) GetSysColorBrush(COLOR_WINDOW); //rueckgabewert von GetSysColorBrush wird gecastet

    /* Register the window class, and if it fails quit the program */
    if (!RegisterClassEx (&amp;wincl))
        return 0;

    /* The class is registered, let's create the program*/
    hwnd = CreateWindowEx (
           0,                   /* Extended possibilites for variation */
           szClassName,         /* Classname */
           &quot;Nicos Alter 4&quot;,       /* Title Text */
           WS_BORDER | WS_SYSMENU, /* thin border, size can't be change with close button */
           CW_USEDEFAULT,       /* Windows decides the position */
           CW_USEDEFAULT,       /* where the window ends up on the screen */
           200,                 /* The programs width */
           120,                 /* and height in pixels */
           HWND_DESKTOP,        /* The window is a child-window to desktop */
           NULL,                /* No menu */
           hThisInstance,       /* Program Instance handler */
           NULL                 /* No Window Creation data */
           );

    /* Make the window visible on the screen */
    ShowWindow (hwnd, nFunsterStil);

    /* Run the message loop. It will run until GetMessage() returns 0 */
    while (GetMessage (&amp;messages, NULL, 0, 0))
    {
        /* Translate virtual-key messages into character messages */
        TranslateMessage(&amp;messages);
        /* Send message to WindowProcedure */
        DispatchMessage(&amp;messages);
    }

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

}

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

LRESULT CALLBACK
WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{

HDC hdc;		/* A device context used for drawing */
PAINTSTRUCT ps;	/* Also used during window drawing */
RECT rc;		/* A rectangle used during drawing */

char cText = 'A';
const UINT TimerID = 1;    
const int iDelay = 1000;        //    = Zeit einstellen

    switch (message)                  /* handle the messages */
    {
        case WM_CREATE:
            {
            	SetTimer(hwnd, TimerID, iDelay, NULL); //Timer setzen
            	return 0;

            }

        case WM_TIMER:
           { 

                if(cText == 'C')
                	cText = 'A';

                else
                	cText++;

                InvalidateRect(hwnd, NULL, TRUE); 
            	return 0;
            	break;

           }    
        case WM_DESTROY:
            {
            	KillTimer(hwnd, TimerID);	//nicht vergessen den Timer zu loeschen!!!
             	PostQuitMessage (0);       /* send a WM_QUIT to the message queue */
            	break;
            }

        case WM_PAINT:
            {
            	/* The window needs to be painted (redrawn). */
            	hdc = BeginPaint (hwnd, &amp;ps);
            	GetClientRect (hwnd, &amp;rc);

                //Hintergrund der Schriftart transparent machen
                SetBkMode(hdc,TRANSPARENT);	

                //den Text ausgeben
                DrawText (hdc, (LPCTSTR) &amp;cText, -1, &amp;rc, 
               	DT_SINGLELINE | DT_CENTER | DT_VCENTER );

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

    return 0;
}
</code></pre>
<p>Vielen Dank fuer eventuelle Tipps!!! <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>
<p>PS<br />
IDE ist DEV C++ falls das wichtig ist</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/85323/warum-zeichnet-sich-das-fenster-nicht-neu</link><generator>RSS for Node</generator><lastBuildDate>Fri, 17 Apr 2026 23:42:40 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/85323.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 07 Sep 2004 18:41:14 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Warum zeichnet sich das Fenster nicht neu??? on Tue, 07 Sep 2004 18:41:14 GMT]]></title><description><![CDATA[<p>Hallo zusammen,</p>
<p>habe es mitlerweile geschaft ein Fenster auf den Bildschirm zu zaubern<br />
welches sich in der groesse nicht veraendern laesst und nur ein X zum<br />
schliessen aufweist.<br />
Hatte mich in letzter Zeit hier mal nach dem Thema Timer erkundigt und<br />
das auch soweit hinbekommen. Getestet mit der MessageBox. <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>Nun mein Problem:<br />
Ich habe hier des oefteren gelesen das</p>
<pre><code class="language-cpp">InvalidateRect(hwnd, NULL, TRUE);
</code></pre>
<p>ein Fenster neu zeichnet, oder zumindestens dafuer sorgt das die WM_PAINT<br />
Message an das Fenster geschickt wird.</p>
<p>Im folgenden Code sollte sich der angezeigte Text sekuendlich von A nach B und<br />
dann nach C aendern und dann wieder von vorn anfangen.<br />
Tut er aber nicht, sondern es steht immer nur das A da! <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f621.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--pouting_face"
      title=":rage:"
      alt="😡"
    /></p>
<p>Jemand eine Idee??? <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f615.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--confused_face"
      title=":confused:"
      alt="😕"
    /></p>
<pre><code class="language-cpp">#include &lt;windows.h&gt;

/*  Declare Windows procedure  */
LRESULT CALLBACK WindowProcedure (HWND, UINT, WPARAM, LPARAM);

/*  Make the class name into a global variable  */
char szClassName[ ] = &quot;WindowsApp&quot;;

int WINAPI
WinMain (HINSTANCE hThisInstance,
         HINSTANCE hPrevInstance,
         LPSTR lpszArgument,
         int nFunsterStil)

{
    HWND hwnd;               /* This is the handle for our window */
    MSG messages;            /* Here messages to the application are saved */
    WNDCLASSEX wincl;        /* Data structure for the windowclass */

    /* The Window structure */
    wincl.hInstance = hThisInstance;
    wincl.lpszClassName = szClassName;
    wincl.lpfnWndProc = WindowProcedure;      /* This function is called by windows */
    wincl.style = CS_DBLCLKS | CS_HREDRAW | CS_VREDRAW;   /* Catch double-clicks */
    wincl.cbSize = sizeof (WNDCLASSEX);

    /* Use default icon and mouse-pointer */
    wincl.hIcon = LoadIcon (NULL, IDI_APPLICATION);
    wincl.hIconSm = LoadIcon (NULL, IDI_APPLICATION);
    wincl.hCursor = LoadCursor (NULL, IDC_ARROW);
    wincl.lpszMenuName = NULL;                 /* No menu */
    wincl.cbClsExtra = 0;                      /* No extra bytes after the window class */
    wincl.cbWndExtra = 0;                      /* structure or the window instance */
    /* Use actual Windows's color as the background of the window */
    wincl.hbrBackground = (HBRUSH) GetSysColorBrush(COLOR_WINDOW); //rueckgabewert von GetSysColorBrush wird gecastet

    /* Register the window class, and if it fails quit the program */
    if (!RegisterClassEx (&amp;wincl))
        return 0;

    /* The class is registered, let's create the program*/
    hwnd = CreateWindowEx (
           0,                   /* Extended possibilites for variation */
           szClassName,         /* Classname */
           &quot;Nicos Alter 4&quot;,       /* Title Text */
           WS_BORDER | WS_SYSMENU, /* thin border, size can't be change with close button */
           CW_USEDEFAULT,       /* Windows decides the position */
           CW_USEDEFAULT,       /* where the window ends up on the screen */
           200,                 /* The programs width */
           120,                 /* and height in pixels */
           HWND_DESKTOP,        /* The window is a child-window to desktop */
           NULL,                /* No menu */
           hThisInstance,       /* Program Instance handler */
           NULL                 /* No Window Creation data */
           );

    /* Make the window visible on the screen */
    ShowWindow (hwnd, nFunsterStil);

    /* Run the message loop. It will run until GetMessage() returns 0 */
    while (GetMessage (&amp;messages, NULL, 0, 0))
    {
        /* Translate virtual-key messages into character messages */
        TranslateMessage(&amp;messages);
        /* Send message to WindowProcedure */
        DispatchMessage(&amp;messages);
    }

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

}

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

LRESULT CALLBACK
WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{

HDC hdc;		/* A device context used for drawing */
PAINTSTRUCT ps;	/* Also used during window drawing */
RECT rc;		/* A rectangle used during drawing */

char cText = 'A';
const UINT TimerID = 1;    
const int iDelay = 1000;        //    = Zeit einstellen

    switch (message)                  /* handle the messages */
    {
        case WM_CREATE:
            {
            	SetTimer(hwnd, TimerID, iDelay, NULL); //Timer setzen
            	return 0;

            }

        case WM_TIMER:
           { 

                if(cText == 'C')
                	cText = 'A';

                else
                	cText++;

                InvalidateRect(hwnd, NULL, TRUE); 
            	return 0;
            	break;

           }    
        case WM_DESTROY:
            {
            	KillTimer(hwnd, TimerID);	//nicht vergessen den Timer zu loeschen!!!
             	PostQuitMessage (0);       /* send a WM_QUIT to the message queue */
            	break;
            }

        case WM_PAINT:
            {
            	/* The window needs to be painted (redrawn). */
            	hdc = BeginPaint (hwnd, &amp;ps);
            	GetClientRect (hwnd, &amp;rc);

                //Hintergrund der Schriftart transparent machen
                SetBkMode(hdc,TRANSPARENT);	

                //den Text ausgeben
                DrawText (hdc, (LPCTSTR) &amp;cText, -1, &amp;rc, 
               	DT_SINGLELINE | DT_CENTER | DT_VCENTER );

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

    return 0;
}
</code></pre>
<p>Vielen Dank fuer eventuelle Tipps!!! <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>
<p>PS<br />
IDE ist DEV C++ falls das wichtig ist</p>
]]></description><link>https://www.c-plusplus.net/forum/post/601912</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/601912</guid><dc:creator><![CDATA[haderlump22]]></dc:creator><pubDate>Tue, 07 Sep 2004 18:41:14 GMT</pubDate></item><item><title><![CDATA[Reply to Warum zeichnet sich das Fenster nicht neu??? on Tue, 07 Sep 2004 18:50:45 GMT]]></title><description><![CDATA[<p>schon mal den Debugger genommen ?</p>
<p>Oder nimm mal UpdateWindow wenn Du eh die client area komplett neu zeichen willst ...</p>
<p>MfG<br />
RB</p>
]]></description><link>https://www.c-plusplus.net/forum/post/601921</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/601921</guid><dc:creator><![CDATA[RED-BARON]]></dc:creator><pubDate>Tue, 07 Sep 2004 18:50:45 GMT</pubDate></item><item><title><![CDATA[Reply to Warum zeichnet sich das Fenster nicht neu??? on Tue, 07 Sep 2004 19:41:28 GMT]]></title><description><![CDATA[<p>Hi,</p>
<pre><code class="language-cpp">UpdateWindow(hwnd);
</code></pre>
<p>hat genau den selben Effekt, den, dass sich gar nichts tut.</p>
<p>Mit der Fehlersuche habe ich auch nichts finden koennen.<br />
Sowohl bei:</p>
<pre><code class="language-cpp">InvalidateRect(hwnd, NULL, TRUE);
</code></pre>
<p>als auch bei:</p>
<pre><code class="language-cpp">UpdateWindow(hwnd);
</code></pre>
<p>laeuft das Programm ganz normal weiter.<br />
Danach laeuft die folgende while Schleife ein paar mal(undefiniert lange!)<br />
durch.</p>
<pre><code class="language-cpp">while (GetMessage (&amp;messages, NULL, 0, 0))
    {
        /* Translate virtual-key messages into character messages */
        TranslateMessage(&amp;messages);
        /* Send message to WindowProcedure */
        DispatchMessage(&amp;messages);
    }
</code></pre>
<p>keine Ahnung was das ist. <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f61e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--disappointed_face"
      title=":("
      alt="😞"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/601968</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/601968</guid><dc:creator><![CDATA[haderlump22]]></dc:creator><pubDate>Tue, 07 Sep 2004 19:41:28 GMT</pubDate></item><item><title><![CDATA[Reply to Warum zeichnet sich das Fenster nicht neu??? on Tue, 07 Sep 2004 21:00:54 GMT]]></title><description><![CDATA[<p>Dein char cText ist nicht statisch, verliert also jedesmal beim verlassen der WndProc mittels return ihren Wert.</p>
<p>Ganz logisch, das dann nach der Zeile</p>
<pre><code class="language-cpp">char cText = 'A';
</code></pre>
<p>nur ein 'A' ausgegeben wird, oder?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/602013</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/602013</guid><dc:creator><![CDATA[Hepi]]></dc:creator><pubDate>Tue, 07 Sep 2004 21:00:54 GMT</pubDate></item><item><title><![CDATA[Reply to Warum zeichnet sich das Fenster nicht neu??? on Wed, 08 Sep 2004 05:55:49 GMT]]></title><description><![CDATA[<p>Juhu,</p>
<p>das wars! Danke!</p>
<p>(habe jetzt nebenbei auch den Sinn von static verstanden) <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/602108</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/602108</guid><dc:creator><![CDATA[haderlump22]]></dc:creator><pubDate>Wed, 08 Sep 2004 05:55:49 GMT</pubDate></item></channel></rss>