<?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[Dialog als Bitmap exportieren]]></title><description><![CDATA[<p>Hallo!</p>
<p>Ich bräuchte mal nen Denkanstoß! Wie kann ich einen Dialog als Bitmap exportieren. Sozusagen ein Screenshot von meinem Dialog und dann speichern. Ach und wie siehts mit .jpg aus? Geht das auch?</p>
<p>Gruß,<br />
Phips</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/62426/dialog-als-bitmap-exportieren</link><generator>RSS for Node</generator><lastBuildDate>Thu, 04 Jun 2026 01:21:10 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/62426.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 23 Jan 2004 09:56:27 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Dialog als Bitmap exportieren on Fri, 23 Jan 2004 09:56:27 GMT]]></title><description><![CDATA[<p>Hallo!</p>
<p>Ich bräuchte mal nen Denkanstoß! Wie kann ich einen Dialog als Bitmap exportieren. Sozusagen ein Screenshot von meinem Dialog und dann speichern. Ach und wie siehts mit .jpg aus? Geht das auch?</p>
<p>Gruß,<br />
Phips</p>
]]></description><link>https://www.c-plusplus.net/forum/post/442416</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/442416</guid><dc:creator><![CDATA[Phips!]]></dc:creator><pubDate>Fri, 23 Jan 2004 09:56:27 GMT</pubDate></item><item><title><![CDATA[Reply to Dialog als Bitmap exportieren on Fri, 23 Jan 2004 12:11:53 GMT]]></title><description><![CDATA[<p>Hi</p>
<p>hab vor ziemlich langer Zeit mal ne Funktion geschrieben.<br />
Darin kannst du sehen, wie sowas funktioniert.<br />
Du musst sie aber ein bisschen abwandeln:</p>
<pre><code class="language-cpp">CBitmap* MakeScreenShot(CWnd* pWnd)
{
	if(pWnd == NULL) return NULL;
	// Das Rechteck, was gezeichnet wird (x = 230, y = 10, Länge x = 8, Länge y = 12):
	int nX = 230;
	int nY = 10;
	int nWidth = 8;
	int nHeight = 12;

	CDC* pSource = pWnd-&gt;GetDC(); // das DC des Fensters
	CDC* pMemDC = new CDC; // das DC, das mit dem Bitmap verknüpft wird
	pMemDC-&gt;CreateCompatibleDC(pSource); // beide DCs gleich

	CBitmap* pBitmap = new CBitmap;
	pBitmap-&gt;CreateCompatibleBitmap(pSource, nWidth, nHeight);
	pBitmap-&gt;SetBitmapDimension(nWidth, nHeight); // damit GetBitmapDimension funktioniert

	pMemDC-&gt;SelectObject(pBitmap);	// pMemDC mit Bitmap verknüpfen
	if(! pMemDC-&gt;BitBlt(0, 0, nWidth, nHeight, pSource, nX, nY, SRCCOPY))
	{
			pMemDC-&gt;DeleteDC();
			delete pMemDC;
			pApp-&gt;ReleaseDC(pSource);
	}
	pMemDC-&gt;DeleteDC();
	delete pMemDC;
	pWnd-&gt;ReleaseDC(pSource);
	return pBitmap; // Bitmap muss nachher UNBEDINGT gelöscht werden
}
</code></pre>
<p>Speichern kannst du das im bmp Format folgendermaßen:</p>
<pre><code class="language-cpp">BOOL WriteBitmap( LPTSTR szFile, HBITMAP hbitmap, HDC memdc)
{
  BITMAP  bmp;
  if(GetObject(hbitmap, sizeof(BITMAP), &amp;bmp))
  {
    BITMAPINFOHEADER BmpInfoHdr;  //Struktur für Bitmap-Infoheader
    BITMAPFILEHEADER BmpFileHdr;  //Struktur für Bitmap-Dateiheader
    BmpInfoHdr.biSize = sizeof(BITMAPINFOHEADER);
    BmpInfoHdr.biWidth = bmp.bmWidth;
    BmpInfoHdr.biHeight = bmp.bmHeight;
    BmpInfoHdr.biPlanes = bmp.bmPlanes;
    BmpInfoHdr.biBitCount = 24;
    BmpInfoHdr.biCompression    = BI_RGB;
    BmpInfoHdr.biSizeImage        = bmp.bmWidth*bmp.bmHeight*3;
    BmpFileHdr.bfType        = 0x4d42;
    BmpFileHdr.bfReserved1        = 0;
    BmpFileHdr.bfReserved2        = 0;
    BmpFileHdr.bfOffBits = sizeof(BITMAPFILEHEADER)+sizeof(BITMAPINFOHEADER);
    BmpFileHdr.bfSize = BmpFileHdr.bfOffBits+BmpInfoHdr.biSizeImage;

    bmp.bmBits = (void*)GlobalAlloc(GMEM_FIXED, BmpInfoHdr.biSizeImage);

    if(GetDIBits(memdc, hbitmap, 0, BmpInfoHdr.biHeight, bmp.bmBits,
        (BITMAPINFO*)&amp;BmpInfoHdr, DIB_RGB_COLORS) == BmpInfoHdr.biHeight)
    {
    HANDLE hFile = CreateFile(szFile, GENERIC_READ | GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL,NULL);
      if(hFile != INVALID_HANDLE_VALUE)  {
        DWORD dwTmp;
        WriteFile(hFile, &amp;BmpFileHdr, sizeof(BITMAPFILEHEADER), &amp;dwTmp, NULL);
        WriteFile(hFile, &amp;BmpInfoHdr, sizeof(BITMAPINFOHEADER), &amp;dwTmp, NULL);
        WriteFile(hFile, bmp.bmBits,  BmpInfoHdr.biSizeImage,   &amp;dwTmp, NULL);
        }
      CloseHandle(hFile);
    }
    GlobalFree(bmp.bmBits);
    return TRUE;
  }
  return FALSE;
}
</code></pre>
<p>Wenn du das Bitmap in einem anderen Format speichern willst, brauchst du eine Klasse, die das kann. Bei Codeguru und Codeprojekt gibts duzente <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>Grüße Rapha</p>
]]></description><link>https://www.c-plusplus.net/forum/post/442513</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/442513</guid><dc:creator><![CDATA[Rapha]]></dc:creator><pubDate>Fri, 23 Jan 2004 12:11:53 GMT</pubDate></item></channel></rss>