<?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[Vorsichtiger Sceensaver Versuch]]></title><description><![CDATA[<p>OK, ich dachte mir ich probiers mal... Compiliert auch fehlerfrei, aber der Bildschirm bleibt schwarz... Weiß mir nicht zu helfen.</p>
<pre><code class="language-cpp">#include &lt;windows.h&gt;
#include &lt;scrnsave.h&gt;

#define ID_TIMER    1
#define NUM 300
int v[NUM];

void fill()
{
    srand((int) GetCurrentTime());
    for (int j=0;j&lt;NUM;++j)
        {
            int a=rand()%10;
            v[j]=a;
        };    
};

LONG WINAPI ScreenSaverProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
    int x1,x2,y1,y2,cx,cy,i=0;
    static HBITMAP hBitmap;
    static HDC hdcMem,hdc;
    PAINTSTRUCT ps;
    switch(message)
    {
        case WM_CREATE:
            SetTimer (hwnd, ID_TIMER, 10, NULL);
            fill();
            cx=GetSystemMetrics(SM_CXSCREEN)/10;
            cy=GetSystemMetrics(SM_CYSCREEN)/10;
            break;
        case WM_TIMER:
            if (i==300) i=100;
            x1=cx*v[i++];
            y1=cy*v[i++];
            x2=cx*v[i++];
            y2=cy+v[i++];
            hdc=BeginPaint(hwnd, &amp;ps);
            hdcMem=CreateCompatibleDC (hdc);
            hBitmap=CreateCompatibleBitmap (hdc, cx, cy);
            SelectObject(hdcMem, hBitmap);
            BitBlt (hdcMem,0,0,cx,cy,hdc,x1,y1, SRCCOPY);
            BitBlt (hdc,x1,y1,cx,cy,hdc,x2,y2, SRCCOPY);
            BitBlt (hdc,x2,y2,cx,cy,hdcMem,0,0, SRCCOPY);
            EndPaint(hwnd, &amp;ps);
            DeleteDC(hdcMem);
            DeleteObject(hBitmap);
            break;
        case WM_DESTROY:
            DeleteDC(hdcMem);
            ReleaseDC(hwnd, hdc);
            DeleteObject(hBitmap);
            break;
   }
   return DefScreenSaverProc(hwnd,message,wParam,lParam);
};

BOOL WINAPI ScreenSaverConfigureDialog(HWND hWnd, UINT message, 
                                       WPARAM wParam, LPARAM lParam)
{
   switch(message)
   {
      case WM_INITDIALOG:
         return TRUE;

      case WM_COMMAND:
         switch(LOWORD(wParam))
         {
            case IDOK:
               EndDialog(hWnd,0);
               return TRUE;

            case IDCANCEL:
               EndDialog(hWnd,0);
               return TRUE;
         }
         break;

   }
   return FALSE;
}

BOOL WINAPI RegisterDialogClasses(HANDLE hInst)
{
   return TRUE;
};
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/topic/86105/vorsichtiger-sceensaver-versuch</link><generator>RSS for Node</generator><lastBuildDate>Sat, 18 Apr 2026 14:50:04 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/86105.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 15 Sep 2004 18:22:04 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Vorsichtiger Sceensaver Versuch on Wed, 15 Sep 2004 18:22:04 GMT]]></title><description><![CDATA[<p>OK, ich dachte mir ich probiers mal... Compiliert auch fehlerfrei, aber der Bildschirm bleibt schwarz... Weiß mir nicht zu helfen.</p>
<pre><code class="language-cpp">#include &lt;windows.h&gt;
#include &lt;scrnsave.h&gt;

#define ID_TIMER    1
#define NUM 300
int v[NUM];

void fill()
{
    srand((int) GetCurrentTime());
    for (int j=0;j&lt;NUM;++j)
        {
            int a=rand()%10;
            v[j]=a;
        };    
};

LONG WINAPI ScreenSaverProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
    int x1,x2,y1,y2,cx,cy,i=0;
    static HBITMAP hBitmap;
    static HDC hdcMem,hdc;
    PAINTSTRUCT ps;
    switch(message)
    {
        case WM_CREATE:
            SetTimer (hwnd, ID_TIMER, 10, NULL);
            fill();
            cx=GetSystemMetrics(SM_CXSCREEN)/10;
            cy=GetSystemMetrics(SM_CYSCREEN)/10;
            break;
        case WM_TIMER:
            if (i==300) i=100;
            x1=cx*v[i++];
            y1=cy*v[i++];
            x2=cx*v[i++];
            y2=cy+v[i++];
            hdc=BeginPaint(hwnd, &amp;ps);
            hdcMem=CreateCompatibleDC (hdc);
            hBitmap=CreateCompatibleBitmap (hdc, cx, cy);
            SelectObject(hdcMem, hBitmap);
            BitBlt (hdcMem,0,0,cx,cy,hdc,x1,y1, SRCCOPY);
            BitBlt (hdc,x1,y1,cx,cy,hdc,x2,y2, SRCCOPY);
            BitBlt (hdc,x2,y2,cx,cy,hdcMem,0,0, SRCCOPY);
            EndPaint(hwnd, &amp;ps);
            DeleteDC(hdcMem);
            DeleteObject(hBitmap);
            break;
        case WM_DESTROY:
            DeleteDC(hdcMem);
            ReleaseDC(hwnd, hdc);
            DeleteObject(hBitmap);
            break;
   }
   return DefScreenSaverProc(hwnd,message,wParam,lParam);
};

BOOL WINAPI ScreenSaverConfigureDialog(HWND hWnd, UINT message, 
                                       WPARAM wParam, LPARAM lParam)
{
   switch(message)
   {
      case WM_INITDIALOG:
         return TRUE;

      case WM_COMMAND:
         switch(LOWORD(wParam))
         {
            case IDOK:
               EndDialog(hWnd,0);
               return TRUE;

            case IDCANCEL:
               EndDialog(hWnd,0);
               return TRUE;
         }
         break;

   }
   return FALSE;
}

BOOL WINAPI RegisterDialogClasses(HANDLE hInst)
{
   return TRUE;
};
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/608079</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/608079</guid><dc:creator><![CDATA[ness]]></dc:creator><pubDate>Wed, 15 Sep 2004 18:22:04 GMT</pubDate></item><item><title><![CDATA[Reply to Vorsichtiger Sceensaver Versuch on Wed, 15 Sep 2004 20:36:42 GMT]]></title><description><![CDATA[<p>Zeichnen solltest du in WM_PAINT - und auch nur dort gehört Begin-/EndPaint hin <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>
]]></description><link>https://www.c-plusplus.net/forum/post/608156</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/608156</guid><dc:creator><![CDATA[flenders]]></dc:creator><pubDate>Wed, 15 Sep 2004 20:36:42 GMT</pubDate></item><item><title><![CDATA[Reply to Vorsichtiger Sceensaver Versuch on Thu, 16 Sep 2004 14:50:28 GMT]]></title><description><![CDATA[<p>Klappt imme noch nicht...<br />
Könnte es sein, das der Bildschirm erst schwarz gemacht wird und dann erst der screenie angemacht wird? Wenn ja, wie kann ich das verhindern?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/608418</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/608418</guid><dc:creator><![CDATA[ness]]></dc:creator><pubDate>Thu, 16 Sep 2004 14:50:28 GMT</pubDate></item><item><title><![CDATA[Reply to Vorsichtiger Sceensaver Versuch on Sat, 18 Sep 2004 16:39:14 GMT]]></title><description><![CDATA[<p>ness schrieb:</p>
<blockquote>
<p>Könnte es sein, das der Bildschirm erst schwarz gemacht wird und dann erst der screenie angemacht wird?</p>
</blockquote>
<p>Nein, dem ist nicht so - wie sieht dein Code denn jetzt aus?!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/609963</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/609963</guid><dc:creator><![CDATA[flenders]]></dc:creator><pubDate>Sat, 18 Sep 2004 16:39:14 GMT</pubDate></item><item><title><![CDATA[Reply to Vorsichtiger Sceensaver Versuch on Sun, 19 Sep 2004 13:00:51 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">#include &lt;windows.h&gt;
#include &lt;scrnsave.h&gt;

#define ID_TIMER    1
#define NUM 1200
int v[NUM];

void fill()
{
    srand((int) GetCurrentTime());
    for (int j=0;j&lt;NUM;++j)
        {
            int a=rand()%10;
            v[j]=a;
        };    
};

LONG WINAPI ScreenSaverProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
    static int x1,x2,y1,y2,cx,cy,i=0;
    static HBITMAP hBitmap;
    static HDC hdcMem,hdc;
    PAINTSTRUCT ps;
    switch(message)
    {
        case WM_CREATE:
            SetTimer (hwnd, ID_TIMER, 10, NULL);
            fill();
            cx=GetSystemMetrics(SM_CXSCREEN)/10;
            cy=GetSystemMetrics(SM_CYSCREEN)/10;
            break;
        case WM_TIMER:
            if (i==NUM)
            {
                i=0;
                fill();
            };    
            x1=cx*v[i++];
            y1=cy*v[i++];
            x2=cx*v[i++];
            y2=cy+v[i++];
            InvalidateRect(hwnd,NULL,TRUE);
        case WM_PAINT:
            hdc=BeginPaint(hwnd, &amp;ps);
            hdcMem=CreateCompatibleDC (hdc);
            hBitmap=CreateCompatibleBitmap (hdc, cx, cy);
            SelectObject(hdcMem, hBitmap);
            BitBlt (hdcMem,0,0,cx,cy,hdc,x1,y1, SRCCOPY);
            BitBlt (hdc,x1,y1,cx,cy,hdc,x2,y2, SRCCOPY);
            BitBlt (hdc,x2,y2,cx,cy,hdcMem,0,0, SRCCOPY);
            EndPaint(hwnd, &amp;ps);
            DeleteDC(hdcMem);
            DeleteObject(hBitmap);
            break;
        case WM_DESTROY:
            DeleteDC(hdcMem);
            ReleaseDC(hwnd, hdc);
            DeleteObject(hBitmap);
            break;
   }
   return DefScreenSaverProc(hwnd,message,wParam,lParam);
};

BOOL WINAPI ScreenSaverConfigureDialog(HWND hWnd, UINT message, 
                                       WPARAM wParam, LPARAM lParam)
{
   switch(message)
   {
      case WM_INITDIALOG:
         return TRUE;

      case WM_COMMAND:
         switch(LOWORD(wParam))
         {
            case IDOK:
               EndDialog(hWnd,0);
               return TRUE;

            case IDCANCEL:
               EndDialog(hWnd,0);
               return TRUE;
         }
         break;

   }
   return FALSE;
}

BOOL WINAPI RegisterDialogClasses(HANDLE hInst)
{
   return TRUE;
};
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/610377</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/610377</guid><dc:creator><![CDATA[ness]]></dc:creator><pubDate>Sun, 19 Sep 2004 13:00:51 GMT</pubDate></item><item><title><![CDATA[Reply to Vorsichtiger Sceensaver Versuch on Sun, 19 Sep 2004 13:48:37 GMT]]></title><description><![CDATA[<p>Wenn du Messages abfängst, dann solltest du am Ende return 0 aufrufen und nicht DefScreenSaverProc. Außerdem fehlt bei WM_TIMER noch ein return 0;<br />
Außerdem fällt mir spontan auf, dass du bei CreateCompatibleBitmap cx und cy also schon die durch 10 geteilten Werte verwendest. Und auch deine BitBlt-Aufrufe (besonders den mittleren) verstehe ich nicht so ganz <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f644.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--face_with_rolling_eyes"
      title=":rolling_eyes:"
      alt="🙄"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/610416</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/610416</guid><dc:creator><![CDATA[flenders]]></dc:creator><pubDate>Sun, 19 Sep 2004 13:48:37 GMT</pubDate></item><item><title><![CDATA[Reply to Vorsichtiger Sceensaver Versuch on Sun, 19 Sep 2004 15:57:25 GMT]]></title><description><![CDATA[<p>Das ist doch wie dreieckstausch! Erst verschieb ich was vom Fenster zum Speicherkontext, dann, ich denke du weißt was Dreieckstausch ist... <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="🙂"
    /><br />
(Achja, bin grad auf Visoal Studio umgestiegen, hab ein paar Startschwierigkeiten)</p>
]]></description><link>https://www.c-plusplus.net/forum/post/610479</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/610479</guid><dc:creator><![CDATA[ness]]></dc:creator><pubDate>Sun, 19 Sep 2004 15:57:25 GMT</pubDate></item><item><title><![CDATA[Reply to Vorsichtiger Sceensaver Versuch on Sun, 19 Sep 2004 18:45:14 GMT]]></title><description><![CDATA[<p>ness schrieb:</p>
<blockquote>
<p>ich denke du weißt was Dreieckstausch ist... <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>
</blockquote>
<p>Das weiß ich schon, nur werden x1,y1 und x2y2 ja zufällig generiert und somit könnte evtl eine Überschneidung der beiden Bereiche auftreten, was beim mittleren BitBlt afaik zu Problemen (undefiniertes Verhalten) führen kann.<br />
Lösung: einfach die beiden letzten BitBlt aus hdcMem heraus blitten.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/610641</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/610641</guid><dc:creator><![CDATA[flenders]]></dc:creator><pubDate>Sun, 19 Sep 2004 18:45:14 GMT</pubDate></item></channel></rss>