<?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[Backbuffering ist kaputt]]></title><description><![CDATA[<p>Hi zusammen,</p>
<p>Irgendwie kommt bei meinen bescheidenen Backbuffering Versuchen nix vernünftiges bei raus. Bekomme zwar das Rechteck aber nur mit nem verrückten Muster und die Farbe ist nicht wirklich ne Farbe....</p>
<p>Was hab ich falsch gemacht???</p>
<pre><code class="language-cpp">case WM_MOUSEMOVE:

	x=LOWORD(lParam);
	y=HIWORD(lParam);

	malen(hwnd,x,y);

	return 0;

case WM_DESTROY:
    PostQuitMessage (0);
    return 0;
}

return DefWindowProc (hwnd, message, wParam, lParam);
}

void malen(HWND hwnd,int x,int y)
{
	PAINTSTRUCT ps;
	RECT rc;
	HDC hdcMem;
	HBITMAP hbmMem;
        HBRUSH hbrDelete;

	hdc = BeginPaint (hwnd, &amp;ps);

	GetClientRect(hwnd,&amp;rc);
	hdcMem = CreateCompatibleDC(hdc);
	hbmMem = CreateCompatibleBitmap
                 (hdcMem,rc.right-rc.left,rc.bottom-rc.top);

	SelectObject(hdcMem,hbmMem);

	hbrDelete = CreateSolidBrush(RGB(255,255,255));
        FillRect(hdcMem, &amp;rc, hbrDelete);
        DeleteObject(hbrDelete);    

	SelectObject(hdcMem,CreateSolidBrush(RGB(0,0,255)));
	Rectangle(hdcMem,x-30,y-30,x+30,y+30);

	hdc=GetDC(hwnd);
	BitBlt(hdc,0,0,rc.right-rc.left,rc.bottom-rc.top,hdcMem,0,0,SRCCOPY);
        ReleaseDC(hwnd,hdc);
	DeleteObject(hbmMem);
	DeleteDC(hdcMem);

	EndPaint (hwnd, &amp;ps);
};
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/topic/83484/backbuffering-ist-kaputt</link><generator>RSS for Node</generator><lastBuildDate>Fri, 17 Apr 2026 11:32:24 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/83484.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 21 Aug 2004 09:59:15 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Backbuffering ist kaputt on Sat, 21 Aug 2004 09:59:15 GMT]]></title><description><![CDATA[<p>Hi zusammen,</p>
<p>Irgendwie kommt bei meinen bescheidenen Backbuffering Versuchen nix vernünftiges bei raus. Bekomme zwar das Rechteck aber nur mit nem verrückten Muster und die Farbe ist nicht wirklich ne Farbe....</p>
<p>Was hab ich falsch gemacht???</p>
<pre><code class="language-cpp">case WM_MOUSEMOVE:

	x=LOWORD(lParam);
	y=HIWORD(lParam);

	malen(hwnd,x,y);

	return 0;

case WM_DESTROY:
    PostQuitMessage (0);
    return 0;
}

return DefWindowProc (hwnd, message, wParam, lParam);
}

void malen(HWND hwnd,int x,int y)
{
	PAINTSTRUCT ps;
	RECT rc;
	HDC hdcMem;
	HBITMAP hbmMem;
        HBRUSH hbrDelete;

	hdc = BeginPaint (hwnd, &amp;ps);

	GetClientRect(hwnd,&amp;rc);
	hdcMem = CreateCompatibleDC(hdc);
	hbmMem = CreateCompatibleBitmap
                 (hdcMem,rc.right-rc.left,rc.bottom-rc.top);

	SelectObject(hdcMem,hbmMem);

	hbrDelete = CreateSolidBrush(RGB(255,255,255));
        FillRect(hdcMem, &amp;rc, hbrDelete);
        DeleteObject(hbrDelete);    

	SelectObject(hdcMem,CreateSolidBrush(RGB(0,0,255)));
	Rectangle(hdcMem,x-30,y-30,x+30,y+30);

	hdc=GetDC(hwnd);
	BitBlt(hdc,0,0,rc.right-rc.left,rc.bottom-rc.top,hdcMem,0,0,SRCCOPY);
        ReleaseDC(hwnd,hdc);
	DeleteObject(hbmMem);
	DeleteDC(hdcMem);

	EndPaint (hwnd, &amp;ps);
};
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/587616</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/587616</guid><dc:creator><![CDATA[Mr.Nobody]]></dc:creator><pubDate>Sat, 21 Aug 2004 09:59:15 GMT</pubDate></item><item><title><![CDATA[Reply to Backbuffering ist kaputt on Sat, 21 Aug 2004 10:17:52 GMT]]></title><description><![CDATA[<p>Du solltest besser bei WM_PAINT malen, nicht bei WM_MOUSEMOVE.</p>
<p>BeginPaint() darf sogar ausschließlich bei WM_PAINT benutzt werden.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/587624</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/587624</guid><dc:creator><![CDATA[Christoph]]></dc:creator><pubDate>Sat, 21 Aug 2004 10:17:52 GMT</pubDate></item><item><title><![CDATA[Reply to Backbuffering ist kaputt on Sat, 21 Aug 2004 10:40:55 GMT]]></title><description><![CDATA[<p>Außerdem solltest du den Backbuffer-DC erst mit FillRect in einen definierten Ausgangszustand versetzen <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f576.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--sunglasses"
      title=":sunglasses:"
      alt="🕶"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/587640</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/587640</guid><dc:creator><![CDATA[flenders]]></dc:creator><pubDate>Sat, 21 Aug 2004 10:40:55 GMT</pubDate></item><item><title><![CDATA[Reply to Backbuffering ist kaputt on Sat, 21 Aug 2004 14:59:51 GMT]]></title><description><![CDATA[<p>@cd9000: Das mit Begin Paint habe ich auch nur gemacht weil es ohne überhaupt net klappt. Das ist die andere Sache die ich net verstehe... warum ist das so??</p>
<p><a class="plugin-mentions-user plugin-mentions-a" href="https://www.c-plusplus.net/forum/uid/1644">@flenders</a>: Dachte eigentlich das ich das gemacht habe <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">hbrDelete = CreateSolidBrush(RGB(255,255,255));
        FillRect(hdcMem, &amp;rc, hbrDelete);
        DeleteObject(hbrDelete);
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/587780</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/587780</guid><dc:creator><![CDATA[Mr.Nobody]]></dc:creator><pubDate>Sat, 21 Aug 2004 14:59:51 GMT</pubDate></item><item><title><![CDATA[Reply to Backbuffering ist kaputt on Sat, 21 Aug 2004 15:15:07 GMT]]></title><description><![CDATA[<p>Mr.Nobody schrieb:</p>
<blockquote>
<p>Das mit Begin Paint habe ich auch nur gemacht weil es ohne überhaupt net klappt. Das ist die andere Sache die ich net verstehe... warum ist das so??</p>
</blockquote>
<p>Zeig bitte mal den Code, der nicht geht.<br />
Wie aber ich aber schon gesagt habe, Zeichnen macht man bei WM_PAINT, nicht bei WM_MOUSEMOVE.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/587787</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/587787</guid><dc:creator><![CDATA[Christoph]]></dc:creator><pubDate>Sat, 21 Aug 2004 15:15:07 GMT</pubDate></item><item><title><![CDATA[Reply to Backbuffering ist kaputt on Sat, 21 Aug 2004 15:24:24 GMT]]></title><description><![CDATA[<p>Da ist er. Versteh echt nicht warum mir die Puffersache so schwer fällt...</p>
<pre><code class="language-cpp">#include &lt;windows.h&gt;

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

HWND hwnd;
HDC hdc;

void malen(HWND,int,int);

int WINAPI WinMain (HINSTANCE hI, HINSTANCE hPrI, PSTR szCmdLine, int iCmdShow)
{
char szName[] = &quot;Fensterklasse&quot;;
WNDCLASS wc;

wc.style         = CS_HREDRAW | CS_VREDRAW;   
wc.lpfnWndProc   = WndProc;
wc.cbClsExtra    = 0;
wc.cbWndExtra    = 0;
wc.hInstance     = hI;
wc.hIcon         = LoadIcon (NULL, IDI_WINLOGO);
wc.hCursor       = LoadCursor (NULL, IDC_ARROW);
wc.hbrBackground = (HBRUSH) CreateSolidBrush(GetSysColor(COLOR_WINDOW));
wc.lpszMenuName  = NULL;
wc.lpszClassName = szName;

RegisterClass (&amp;wc);

hwnd = CreateWindow (szName, &quot;&quot;, WS_SYSMENU | WS_THICKFRAME, 
                          0, 0, 800, 600, NULL, NULL, hI, NULL);

ShowWindow   (hwnd, iCmdShow);
UpdateWindow (hwnd);

MSG msg;
    while (GetMessage (&amp;msg, NULL, 0, 0))
    {
        TranslateMessage (&amp;msg);
        DispatchMessage (&amp;msg);
    }
return msg.wParam;
}

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

PAINTSTRUCT ps;
int x,y;

switch (message)
{
case WM_PAINT:
    hdc = BeginPaint (hwnd, &amp;ps);
    EndPaint (hwnd, &amp;ps);
    return 0;

case WM_MOUSEMOVE:

	x=LOWORD(lParam);
	y=HIWORD(lParam);

	malen(hwnd,x,y);

	return 0;

case WM_DESTROY:
    PostQuitMessage (0);
    return 0;
}

return DefWindowProc (hwnd, message, wParam, lParam);
}

void malen(HWND hwnd,int x,int y)
{
	PAINTSTRUCT ps;
	RECT rc;
	HDC hdcMem;
	HBITMAP hbmMem;
    HBRUSH hbrDelete;

	hdc = BeginPaint (hwnd, &amp;ps);

	GetClientRect(hwnd,&amp;rc);
	hdcMem = CreateCompatibleDC(hdc);
	hbmMem = CreateCompatibleBitmap(hdcMem,rc.right-rc.left,rc.bottom-rc.top);

	SelectObject(hdcMem,hbmMem);

	hbrDelete = CreateSolidBrush(RGB(255,255,255));
    FillRect(hdcMem, &amp;rc, hbrDelete);
    DeleteObject(hbrDelete);    

	SelectObject(hdcMem,CreateSolidBrush(RGB(0,0,255)));
	Rectangle(hdcMem,x-30,y-30,x+30,y+30);

	hdc=GetDC(hwnd);
	BitBlt(hdc,0,0,rc.right-rc.left,rc.bottom-rc.top,hdcMem,0,0,SRCCOPY);
    ReleaseDC(hwnd,hdc);
	DeleteObject(hbmMem);
	DeleteDC(hdcMem);

	EndPaint (hwnd, &amp;ps);
};
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/587792</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/587792</guid><dc:creator><![CDATA[Mr.Nobody]]></dc:creator><pubDate>Sat, 21 Aug 2004 15:24:24 GMT</pubDate></item><item><title><![CDATA[Reply to Backbuffering ist kaputt on Sat, 21 Aug 2004 20:11:13 GMT]]></title><description><![CDATA[<p>Und zum dritten Mal: Ruf die Funktion malen() bei WM_PAINT und nicht bei WM_MOUSEMOVE auf. <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/587985</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/587985</guid><dc:creator><![CDATA[Christoph]]></dc:creator><pubDate>Sat, 21 Aug 2004 20:11:13 GMT</pubDate></item><item><title><![CDATA[Reply to Backbuffering ist kaputt on Sat, 21 Aug 2004 20:13:05 GMT]]></title><description><![CDATA[<p>Mr.Nobody schrieb:</p>
<blockquote>
<p><a class="plugin-mentions-user plugin-mentions-a" href="https://www.c-plusplus.net/forum/uid/1644">@flenders</a>: Dachte eigentlich das ich das gemacht habe <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">hbrDelete = CreateSolidBrush(RGB(255,255,255));
        FillRect(hdcMem, &amp;rc, hbrDelete);
        DeleteObject(hbrDelete);
</code></pre>
</blockquote>
<p>Sorry, hatte ich irgendwie völlig übersehen <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>
<p>Mr.Nobody schrieb:</p>
<blockquote>
<p>@cd9000: Das mit Begin Paint habe ich auch nur gemacht weil es ohne überhaupt net klappt. Das ist die andere Sache die ich net verstehe... warum ist das so??</p>
</blockquote>
<p>Wie schon gesagt - zeichnen eigentlich nur in WM_PAINT. Für deinen Code würde ich dann x und y static machen und in WM_MOUSEMOVE einfach InvalidateRect aufrufen (dadurch bekommst du eine WM_PAINT-Nachricht) - in WM_PAINT kannst du dann von mir aus deine malen-Funktion aufrufen (aber dann in WM_PAINT dein Begin-/EndPaint rausnehmen) <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/587988</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/587988</guid><dc:creator><![CDATA[flenders]]></dc:creator><pubDate>Sat, 21 Aug 2004 20:13:05 GMT</pubDate></item><item><title><![CDATA[Reply to Backbuffering ist kaputt on Sun, 22 Aug 2004 12:39:32 GMT]]></title><description><![CDATA[<p>Hi,<br />
Hab alles gemacht was ihr mir vorgeschlagen habt. Aber es ist nach wie vor das gleiche <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="😡"
    /><br />
Wenn ich direkt mit dem hdc zeichene klappts. Aber wenn ich kann die f*** Sachen speichere bakomm ich son f*** angezeigt. Alsob ich durch das Rechteck auf ein Muster im hintergrund guck....</p>
<p>p.s. das das keinen großen Sinn macht was ich das programmieren will weiß ich.<br />
Würds aber gern verstehen.</p>
<pre><code class="language-cpp">#include &lt;windows.h&gt;

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

HWND hwnd;
HDC hdc;

void malen(HWND,int,int);

int WINAPI WinMain (HINSTANCE hI, HINSTANCE hPrI, PSTR szCmdLine, int iCmdShow)
{
char szName[] = &quot;Fensterklasse&quot;;
WNDCLASS wc;

wc.style         = CS_HREDRAW | CS_VREDRAW;   // CS = &quot;class style&quot;
wc.lpfnWndProc   = WndProc;
wc.cbClsExtra    = 0;
wc.cbWndExtra    = 0;
wc.hInstance     = hI;
wc.hIcon         = LoadIcon (NULL, IDI_WINLOGO);
wc.hCursor       = LoadCursor (NULL, IDC_ARROW);
wc.hbrBackground = (HBRUSH) CreateSolidBrush(GetSysColor(COLOR_WINDOW));
wc.lpszMenuName  = NULL;
wc.lpszClassName = szName;

RegisterClass (&amp;wc);

hwnd = CreateWindow (szName, &quot;&quot;, WS_SYSMENU | WS_THICKFRAME, 
                          0, 0, 800, 600, NULL, NULL, hI, NULL);

ShowWindow   (hwnd, iCmdShow);
UpdateWindow (hwnd);

MSG msg;
    while (GetMessage (&amp;msg, NULL, 0, 0))
    {
        TranslateMessage (&amp;msg);
        DispatchMessage (&amp;msg);
    }
return msg.wParam;
}

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

PAINTSTRUCT ps;
static int x,y;

switch (message)
{
case WM_PAINT:

	hdc = BeginPaint (hwnd, &amp;ps);
    malen(hwnd,x,y);
	EndPaint (hwnd, &amp;ps);
    return 0;

case WM_MOUSEMOVE:

	x=LOWORD(lParam);
	y=HIWORD(lParam);
	InvalidateRect(hwnd,NULL,FALSE);
	return 0;

case WM_DESTROY:

	PostQuitMessage (0);
    return 0;
}

return DefWindowProc (hwnd, message, wParam, lParam);
}

void malen(HWND hwnd,int x,int y)
{

	RECT rc,Rect;
	HDC hdcMem;
	HBITMAP hbmMem;
    HBRUSH hbrDelete,hbrFarbe1;

	//Tolle Sachen machen
	GetClientRect(hwnd,&amp;rc);
	hdcMem = CreateCompatibleDC(hdc);
	hbmMem = CreateCompatibleBitmap(hdcMem,rc.right-rc.left,rc.bottom-rc.top);
    SelectObject(hdcMem,hbmMem);

	//Feld leeren
	hbrDelete = CreateSolidBrush(RGB(255,255,255));
    FillRect(hdcMem, &amp;rc, hbrDelete);
    DeleteObject(hbrDelete);    

	//Zeichnen
	hbrFarbe1 = CreateSolidBrush(RGB(0,0,255));
	SetRect(&amp;Rect,x-30,y-30,x+30,y+30);
	FillRect(hdcMem, &amp;Rect, hbrFarbe1);
    DeleteObject(hbrFarbe1);

    //Kopieren
	BitBlt(hdc,0,0,rc.right-rc.left,rc.bottom-rc.top,hdcMem,0,0,SRCCOPY);
	DeleteObject(hbmMem);
	DeleteDC(hdcMem);

};
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/588267</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/588267</guid><dc:creator><![CDATA[Mr.Nobody]]></dc:creator><pubDate>Sun, 22 Aug 2004 12:39:32 GMT</pubDate></item><item><title><![CDATA[Reply to Backbuffering ist kaputt on Sun, 22 Aug 2004 12:49:36 GMT]]></title><description><![CDATA[<p>Du musst dein CreateCompatibleBitmap mit dem Handle des richtigen DCs aufrufen, denn der Memory-DC ist nach dem Erstellen schwarz-weiß.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/588285</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/588285</guid><dc:creator><![CDATA[flenders]]></dc:creator><pubDate>Sun, 22 Aug 2004 12:49:36 GMT</pubDate></item><item><title><![CDATA[Reply to Backbuffering ist kaputt on Sun, 22 Aug 2004 13:20:21 GMT]]></title><description><![CDATA[<p>Ahh sag das doch gleich <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>Jetzt klappts</p>
<p>Also kann ich die Farbe von dem monochromen bitmap was ich erzeugt habe nicht verändern.(momochrom halt)<br />
Und wenn ich den hdc direkt hole bekomm ich ein farbiges BITMAP.</p>
<p>Hoffe hab das jetzt richtig verstanden</p>
<p>Danke für die Hilfe wär ich nie drauf gekommen</p>
]]></description><link>https://www.c-plusplus.net/forum/post/588312</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/588312</guid><dc:creator><![CDATA[Mr.Nobody]]></dc:creator><pubDate>Sun, 22 Aug 2004 13:20:21 GMT</pubDate></item></channel></rss>