<?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 als Hintergrundbild eines Dialoges]]></title><description><![CDATA[<p>Hallo!</p>
<p>ich hab ein Problem mit meinem Programm...<br />
ich lade ein Bitmap und möchte dieses als Hintergrund für meinen Dialog, also anstatt dem 'grau' mein bild.<br />
das laden funktioniert auch alles soweit, nur das anzeigen... das geht nicht</p>
<p>ich benutze dazu die Funktion StretchDIBits in der Dialogroutine bei Nachricht WM_ERASEBKGND</p>
<p>also:</p>
<p>...</p>
<pre><code>BYTE *LoadDIBImage(char *image)
{
	DWORD dwFileSize, dwBytesRead;
	HANDLE hFile;
	BYTE *pData;

	hFile=CreateFile(image,GENERIC_READ,0,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,NULL);
	if(hFile==INVALID_HANDLE_VALUE)
		return NULL;

	dwFileSize=GetFileSize(hFile,NULL);

	pData=(BYTE *)malloc(dwFileSize);
	if(pData==NULL) {
		CloseHandle(hFile);
		return NULL;
	}

	ReadFile(hFile,pData,dwFileSize,&amp;dwBytesRead,NULL);
	if(dwFileSize!=dwBytesRead) {
		CloseHandle(hFile);
		free(pData);
		return NULL;
	}

	return pData;
}

case WM_INITDIALOG:
...
pbmfh=(BITMAPFILEHEADER *)LoadImage(name);
pbmi=(BITMAPINFO *)(pbmfh+1);
pBits=(BYTE *)pbmfh + pbmfh-&gt;bfOffbits;
sizex=pbmi-&gt;bmiHeader.biWidth;
sizey=pbmi-&gt;bmiHeader.biHeight;
...
return TRUE;

case WM_ERASEBKND:
hdc=(HDC)wParam;
GetClientRect(hwndDlg,&amp;r);
StretchDIBits(hdc,0,0,r.right,r.bottom,0,0,sizex,sizey,pBits,pbmi,DIB_RGB_COLORS,SRCCOPY);
return TRUE;
</code></pre>
<p>Der Dialog ist immer ganz schwarz!</p>
<p>Kann mir da jemand bitte weiterhelfen?<br />
weiß nicht mehr weiter...</p>
<p>Danke...<br />
mfg</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/90018/bitmap-als-hintergrundbild-eines-dialoges</link><generator>RSS for Node</generator><lastBuildDate>Tue, 21 Apr 2026 21:46:18 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/90018.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 25 Oct 2004 15:44:50 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Bitmap als Hintergrundbild eines Dialoges on Mon, 25 Oct 2004 15:44:50 GMT]]></title><description><![CDATA[<p>Hallo!</p>
<p>ich hab ein Problem mit meinem Programm...<br />
ich lade ein Bitmap und möchte dieses als Hintergrund für meinen Dialog, also anstatt dem 'grau' mein bild.<br />
das laden funktioniert auch alles soweit, nur das anzeigen... das geht nicht</p>
<p>ich benutze dazu die Funktion StretchDIBits in der Dialogroutine bei Nachricht WM_ERASEBKGND</p>
<p>also:</p>
<p>...</p>
<pre><code>BYTE *LoadDIBImage(char *image)
{
	DWORD dwFileSize, dwBytesRead;
	HANDLE hFile;
	BYTE *pData;

	hFile=CreateFile(image,GENERIC_READ,0,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,NULL);
	if(hFile==INVALID_HANDLE_VALUE)
		return NULL;

	dwFileSize=GetFileSize(hFile,NULL);

	pData=(BYTE *)malloc(dwFileSize);
	if(pData==NULL) {
		CloseHandle(hFile);
		return NULL;
	}

	ReadFile(hFile,pData,dwFileSize,&amp;dwBytesRead,NULL);
	if(dwFileSize!=dwBytesRead) {
		CloseHandle(hFile);
		free(pData);
		return NULL;
	}

	return pData;
}

case WM_INITDIALOG:
...
pbmfh=(BITMAPFILEHEADER *)LoadImage(name);
pbmi=(BITMAPINFO *)(pbmfh+1);
pBits=(BYTE *)pbmfh + pbmfh-&gt;bfOffbits;
sizex=pbmi-&gt;bmiHeader.biWidth;
sizey=pbmi-&gt;bmiHeader.biHeight;
...
return TRUE;

case WM_ERASEBKND:
hdc=(HDC)wParam;
GetClientRect(hwndDlg,&amp;r);
StretchDIBits(hdc,0,0,r.right,r.bottom,0,0,sizex,sizey,pBits,pbmi,DIB_RGB_COLORS,SRCCOPY);
return TRUE;
</code></pre>
<p>Der Dialog ist immer ganz schwarz!</p>
<p>Kann mir da jemand bitte weiterhelfen?<br />
weiß nicht mehr weiter...</p>
<p>Danke...<br />
mfg</p>
]]></description><link>https://www.c-plusplus.net/forum/post/637233</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/637233</guid><dc:creator><![CDATA[Heike27]]></dc:creator><pubDate>Mon, 25 Oct 2004 15:44:50 GMT</pubDate></item><item><title><![CDATA[Reply to Bitmap als Hintergrundbild eines Dialoges on Mon, 25 Oct 2004 16:18:17 GMT]]></title><description><![CDATA[<p>Warum nimmst du nicht LoadBitmap/LoadImage, CreateCompatibleDC, SelectObject, StrechBlt - scheint mir irgendwie einfacher zu sein <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/637268</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/637268</guid><dc:creator><![CDATA[flenders]]></dc:creator><pubDate>Mon, 25 Oct 2004 16:18:17 GMT</pubDate></item><item><title><![CDATA[Reply to Bitmap als Hintergrundbild eines Dialoges on Mon, 25 Oct 2004 22:16:38 GMT]]></title><description><![CDATA[<p>flenders schrieb:</p>
<blockquote>
<p>Warum nimmst du nicht LoadBitmap/LoadImage, CreateCompatibleDC, SelectObject, StrechBlt - scheint mir irgendwie einfacher zu sein <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>
</blockquote>
<p>Kommt drauf an, ich denke das hat einen anderen gewissen Grund, nicht den Anfängerweg zu gehen.</p>
<p><a class="plugin-mentions-user plugin-mentions-a" href="https://www.c-plusplus.net/forum/uid/3557">@heike</a><br />
wann wird den &quot;WM_ERASEBKND&quot; gesendet? <strong>Nie</strong></p>
<p>aber ab und an kommt mal ein &quot;WM_ERASEBKGND&quot;, zum beispiel nach einem Resize<br />
oder InvalidateRect</p>
]]></description><link>https://www.c-plusplus.net/forum/post/637532</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/637532</guid><dc:creator><![CDATA[MiC++ha]]></dc:creator><pubDate>Mon, 25 Oct 2004 22:16:38 GMT</pubDate></item></channel></rss>