<?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[Bitmap anzeigen, will net :(]]></title><description><![CDATA[<p>Hi,</p>
<p>ich verzweifle langsam... wieso wird kein bild angezeigt?</p>
<pre><code class="language-cpp">LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
	HBITMAP bmp_Background = NULL;

	switch (message)
	{
	case WM_CREATE:
		{
			bmp_Background = LoadBitmap(GetModuleHandle(NULL), &quot;test.bmp&quot;);

			RECT rc = {0, 0, 640, 480};

			::AdjustWindowRectEx (&amp;rc, window_style, false, 0);

			int centerX = (::GetSystemMetrics(SM_CXFULLSCREEN)/2) - (abs(rc.left)+rc.right )/2;
			int centerY = (::GetSystemMetrics(SM_CYFULLSCREEN)/2) - (abs(rc.top )+rc.bottom)/2; 

			::MoveWindow (hWnd, centerX, centerY, (rc.right - rc.left), (rc.bottom - rc.top), true);
		} break;

    case WM_PAINT:
    {
        BITMAP bm;
        PAINTSTRUCT ps;

        HDC hdc = BeginPaint(hWnd, &amp;ps);

        HDC hdcMem = CreateCompatibleDC(hdc);
        HBITMAP hbmOld = SelectObject(hdcMem, g_hbmBall);

        GetObject(g_hbmBall, sizeof(bm), &amp;bm);

        BitBlt(hdc, 0, 0, bm.bmWidth, bm.bmHeight, hdcMem, 0, 0, SRCCOPY);

        SelectObject(hdcMem, hbmOld);
        DeleteDC(hdcMem);

        EndPaint(hWnd, &amp;ps);
    }
    break;

	case WM_DESTROY:
		{
			if (bmp_Background != NULL)
			{
				::DeleteObject (bmp_Background);
				bmp_Background = NULL;
			}

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

	return ::DefWindowProc(hWnd, message, wParam, lParam);
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/topic/81102/bitmap-anzeigen-will-net</link><generator>RSS for Node</generator><lastBuildDate>Mon, 13 Apr 2026 11:27:13 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/81102.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 27 Jul 2004 22:12:45 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Bitmap anzeigen, will net :( on Tue, 27 Jul 2004 22:12:45 GMT]]></title><description><![CDATA[<p>Hi,</p>
<p>ich verzweifle langsam... wieso wird kein bild angezeigt?</p>
<pre><code class="language-cpp">LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
	HBITMAP bmp_Background = NULL;

	switch (message)
	{
	case WM_CREATE:
		{
			bmp_Background = LoadBitmap(GetModuleHandle(NULL), &quot;test.bmp&quot;);

			RECT rc = {0, 0, 640, 480};

			::AdjustWindowRectEx (&amp;rc, window_style, false, 0);

			int centerX = (::GetSystemMetrics(SM_CXFULLSCREEN)/2) - (abs(rc.left)+rc.right )/2;
			int centerY = (::GetSystemMetrics(SM_CYFULLSCREEN)/2) - (abs(rc.top )+rc.bottom)/2; 

			::MoveWindow (hWnd, centerX, centerY, (rc.right - rc.left), (rc.bottom - rc.top), true);
		} break;

    case WM_PAINT:
    {
        BITMAP bm;
        PAINTSTRUCT ps;

        HDC hdc = BeginPaint(hWnd, &amp;ps);

        HDC hdcMem = CreateCompatibleDC(hdc);
        HBITMAP hbmOld = SelectObject(hdcMem, g_hbmBall);

        GetObject(g_hbmBall, sizeof(bm), &amp;bm);

        BitBlt(hdc, 0, 0, bm.bmWidth, bm.bmHeight, hdcMem, 0, 0, SRCCOPY);

        SelectObject(hdcMem, hbmOld);
        DeleteDC(hdcMem);

        EndPaint(hWnd, &amp;ps);
    }
    break;

	case WM_DESTROY:
		{
			if (bmp_Background != NULL)
			{
				::DeleteObject (bmp_Background);
				bmp_Background = NULL;
			}

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

	return ::DefWindowProc(hWnd, message, wParam, lParam);
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/569928</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/569928</guid><dc:creator><![CDATA[---]]></dc:creator><pubDate>Tue, 27 Jul 2004 22:12:45 GMT</pubDate></item><item><title><![CDATA[Reply to Bitmap anzeigen, will net :( on Tue, 27 Jul 2004 22:55:16 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">HBITMAP bmp_Background = NULL;
</code></pre>
<p>Schreib mal ein static vor das HBITMAP. Ansonsten erzeugst du eine normale lokale Variable auf dem Stack, die bei jedem Aufruf wieder 0 ist.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/569943</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/569943</guid><dc:creator><![CDATA[Christoph]]></dc:creator><pubDate>Tue, 27 Jul 2004 22:55:16 GMT</pubDate></item><item><title><![CDATA[Reply to Bitmap anzeigen, will net :( on Thu, 29 Jul 2004 14:29:06 GMT]]></title><description><![CDATA[<p>hier ein Beispielcode:</p>
<p>HANDLE hBitmap</p>
<p>hBitmap = (HBITMAP)LoadImage(NULL,&quot;test.bmp&quot;,IMAGE_BITMAP,0,0,LR_LOADFROMFILE);<br />
int width = 640;<br />
int height = 480;</p>
<p>switch(message)<br />
{<br />
case WM_PAINT:<br />
{<br />
PAINTSTRUCT ps;<br />
HDC hDC;</p>
<p>hDC = BeginPaint(hWnd, &amp;ps);<br />
{</p>
<p>HDC BhDC = CreateCompatibleDC(hDC);<br />
SelectObject(BhDC,hBitmap);<br />
BitBlt(hDC,0,0,width,height,BhDC,0,0,SRCCOPY);<br />
}<br />
EndPaint(hWnd, &amp;ps);<br />
return 0;<br />
}</p>
<p>das muesste eigentlich einwandfrei funktionieren!!</p>
<p>nicht vergessen: den reservierten speicherplatz von hBitmap wieder frei zu geben</p>
]]></description><link>https://www.c-plusplus.net/forum/post/571043</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/571043</guid><dc:creator><![CDATA[Moh]]></dc:creator><pubDate>Thu, 29 Jul 2004 14:29:06 GMT</pubDate></item></channel></rss>