<?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[Screen von Fenster und teil rausschneiden]]></title><description><![CDATA[<p>Wie kann ich ein Screenshot von einem Fenster machen (im Code unten macht es nur eins von Desktop) und daraus dann ein teil (pixel x,y bis x,y) rausscheiden?</p>
<pre><code class="language-cpp">#include &lt;windows.h&gt;
#include &lt;string&gt;

{

          HDC hdcScreen;

          HBITMAP hbmScreen;

          //---------------Bitmap Informationen

          BITMAPINFO infobmp;

          infobmp.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);

          infobmp.bmiHeader.biWidth = 1024;

          infobmp.bmiHeader.biHeight = 768;

          infobmp.bmiHeader.biPlanes = 1;

          infobmp.bmiHeader.biBitCount = 24;

          infobmp.bmiHeader.biCompression = 0;

          infobmp.bmiHeader.biSizeImage = 0;

          infobmp.bmiHeader.biXPelsPerMeter = 0;

          infobmp.bmiHeader.biYPelsPerMeter = 0;

          infobmp.bmiHeader.biClrUsed = 0;

          infobmp.bmiHeader.biClrImportant = 0;

          int* bitmap = new int[1024*768*3];

          BITMAPFILEHEADER bfheader;

          bfheader.bfType = 19778;

          bfheader.bfSize = sizeof(BITMAPFILEHEADER) + 1024*768*3 + sizeof(BITMAPINFOHEADER);

          bfheader.bfReserved1 = 0;

          bfheader.bfReserved2 = 0;

          bfheader.bfOffBits = sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER);

          //Bitmap -----------------------      Informationen

          hdcScreen = GetWindowDC(pScreen);

          hbmScreen = CreateCompatibleBitmap(hdcScreen,1024,768);

          // temporärer DC

          HDC hdcTemp = CreateCompatibleDC( hdcScreen );

          // Bitmap reinselektieren

          HBITMAP hbmOld = (HBITMAP)SelectObject( hdcTemp, hbmScreen );

          // Inhalt von Desktop übertragen

          BitBlt( hdcTemp, 0, 0, 1024, 768, hdcScreen, 0, 0, SRCCOPY );

          int iResult = GetDIBits(hdcTemp,hbmScreen,0,768,bitmap,&amp;infobmp,DIB_RGB_COLORS);

          // aufräumen

          SelectObject( hdcTemp, hbmOld );

          DeleteObject( hbmScreen );

          DeleteDC( hdcTemp );

          HANDLE hfile = CreateFile( Path,GENERIC_WRITE,0,0,OPEN_ALWAYS,0,0);

          //Datei Schreiben

          DWORD word;

        WriteFile(hfile,&amp;bfheader,14,&amp;word,NULL);

          WriteFile(hfile,&amp;infobmp,40,&amp;word,NULL);

          WriteFile(hfile,bitmap,1024*768*3,&amp;word,NULL);

            ReleaseDC(pScreen,hdcScreen);

          CloseHandle(hfile);

          delete[] bitmap;

      }
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/topic/224044/screen-von-fenster-und-teil-rausschneiden</link><generator>RSS for Node</generator><lastBuildDate>Sun, 12 Apr 2026 02:00:03 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/224044.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 04 Oct 2008 18:46:48 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Screen von Fenster und teil rausschneiden on Sat, 04 Oct 2008 18:46:48 GMT]]></title><description><![CDATA[<p>Wie kann ich ein Screenshot von einem Fenster machen (im Code unten macht es nur eins von Desktop) und daraus dann ein teil (pixel x,y bis x,y) rausscheiden?</p>
<pre><code class="language-cpp">#include &lt;windows.h&gt;
#include &lt;string&gt;

{

          HDC hdcScreen;

          HBITMAP hbmScreen;

          //---------------Bitmap Informationen

          BITMAPINFO infobmp;

          infobmp.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);

          infobmp.bmiHeader.biWidth = 1024;

          infobmp.bmiHeader.biHeight = 768;

          infobmp.bmiHeader.biPlanes = 1;

          infobmp.bmiHeader.biBitCount = 24;

          infobmp.bmiHeader.biCompression = 0;

          infobmp.bmiHeader.biSizeImage = 0;

          infobmp.bmiHeader.biXPelsPerMeter = 0;

          infobmp.bmiHeader.biYPelsPerMeter = 0;

          infobmp.bmiHeader.biClrUsed = 0;

          infobmp.bmiHeader.biClrImportant = 0;

          int* bitmap = new int[1024*768*3];

          BITMAPFILEHEADER bfheader;

          bfheader.bfType = 19778;

          bfheader.bfSize = sizeof(BITMAPFILEHEADER) + 1024*768*3 + sizeof(BITMAPINFOHEADER);

          bfheader.bfReserved1 = 0;

          bfheader.bfReserved2 = 0;

          bfheader.bfOffBits = sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER);

          //Bitmap -----------------------      Informationen

          hdcScreen = GetWindowDC(pScreen);

          hbmScreen = CreateCompatibleBitmap(hdcScreen,1024,768);

          // temporärer DC

          HDC hdcTemp = CreateCompatibleDC( hdcScreen );

          // Bitmap reinselektieren

          HBITMAP hbmOld = (HBITMAP)SelectObject( hdcTemp, hbmScreen );

          // Inhalt von Desktop übertragen

          BitBlt( hdcTemp, 0, 0, 1024, 768, hdcScreen, 0, 0, SRCCOPY );

          int iResult = GetDIBits(hdcTemp,hbmScreen,0,768,bitmap,&amp;infobmp,DIB_RGB_COLORS);

          // aufräumen

          SelectObject( hdcTemp, hbmOld );

          DeleteObject( hbmScreen );

          DeleteDC( hdcTemp );

          HANDLE hfile = CreateFile( Path,GENERIC_WRITE,0,0,OPEN_ALWAYS,0,0);

          //Datei Schreiben

          DWORD word;

        WriteFile(hfile,&amp;bfheader,14,&amp;word,NULL);

          WriteFile(hfile,&amp;infobmp,40,&amp;word,NULL);

          WriteFile(hfile,bitmap,1024*768*3,&amp;word,NULL);

            ReleaseDC(pScreen,hdcScreen);

          CloseHandle(hfile);

          delete[] bitmap;

      }
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1593431</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1593431</guid><dc:creator><![CDATA[plshelp]]></dc:creator><pubDate>Sat, 04 Oct 2008 18:46:48 GMT</pubDate></item><item><title><![CDATA[Reply to Screen von Fenster und teil rausschneiden on Sat, 04 Oct 2008 18:58:21 GMT]]></title><description><![CDATA[<p>Du ermittelst die Größe und Position des Fensters und macht eben von nur einem Teil des &quot;Desktops&quot; den Screenshot.</p>
<p>Ansonsten siehe WM_PRINT bzw. WM_PRINTCLINET, was aber von nicht sher vielen Anwendungen unterstützt wird.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1593436</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1593436</guid><dc:creator><![CDATA[Jochen Kalmbach]]></dc:creator><pubDate>Sat, 04 Oct 2008 18:58:21 GMT</pubDate></item><item><title><![CDATA[Reply to Screen von Fenster und teil rausschneiden on Sat, 04 Oct 2008 19:04:10 GMT]]></title><description><![CDATA[<blockquote>
<p>Du ermittelst die Größe und Position des Fensters und macht eben von nur einem Teil des &quot;Desktops&quot; den Screenshot.</p>
</blockquote>
<p>ja, und wie?</p>
<p>Wie ich ein teil rauschschneide, weiß ich ha auch nicht.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1593438</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1593438</guid><dc:creator><![CDATA[plshelp]]></dc:creator><pubDate>Sat, 04 Oct 2008 19:04:10 GMT</pubDate></item><item><title><![CDATA[Reply to Screen von Fenster und teil rausschneiden on Sat, 04 Oct 2008 19:06:02 GMT]]></title><description><![CDATA[<p>Du brauchst dazu das &quot;hWnd&quot; des Fensters... Frag jetzt nicht wie Du das bekommst... das musst Du selber wissen! Oder schau mal EnumWindows an...</p>
<p>Und dann würde ich ganz spontan &quot;GetWindowRect&quot; verwenden...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1593440</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1593440</guid><dc:creator><![CDATA[Jochen Kalmbach]]></dc:creator><pubDate>Sat, 04 Oct 2008 19:06:02 GMT</pubDate></item><item><title><![CDATA[Reply to Screen von Fenster und teil rausschneiden on Sat, 04 Oct 2008 21:03:04 GMT]]></title><description><![CDATA[<blockquote>
<p>Du brauchst dazu das &quot;hWnd&quot; des Fensters... Frag jetzt nicht wie Du das bekommst... das musst Du selber wissen!</p>
</blockquote>
<p>Das weiß ich ja, aber wie mache ich davon nun ein foto?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1593472</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1593472</guid><dc:creator><![CDATA[plshelp]]></dc:creator><pubDate>Sat, 04 Oct 2008 21:03:04 GMT</pubDate></item><item><title><![CDATA[Reply to Screen von Fenster und teil rausschneiden on Sun, 05 Oct 2008 00:08:34 GMT]]></title><description><![CDATA[<blockquote>
<p>Zitat:<br />
Du brauchst dazu das &quot;hWnd&quot; des Fensters... Frag jetzt nicht wie Du das bekommst... das musst Du selber wissen!</p>
<p>Das weiß ich ja, aber wie mache ich davon nun ein foto?</p>
</blockquote>
<p>Falsche frage. Sorry. Wie mache ich davon denn ein teilausschnitt?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1593531</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1593531</guid><dc:creator><![CDATA[plshelp]]></dc:creator><pubDate>Sun, 05 Oct 2008 00:08:34 GMT</pubDate></item><item><title><![CDATA[Reply to Screen von Fenster und teil rausschneiden on Sun, 05 Oct 2008 00:48:26 GMT]]></title><description><![CDATA[<p>Kopier halt einfach weniger Daten? Wo liegt genau das Problem?<br />
Dein BitBlt() z.B. kopiert nen Bereich von 1024x768, setzt man das kleiner hat man nen kleineren Bereich kopiert?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1593540</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1593540</guid><dc:creator><![CDATA[geeky]]></dc:creator><pubDate>Sun, 05 Oct 2008 00:48:26 GMT</pubDate></item><item><title><![CDATA[Reply to Screen von Fenster und teil rausschneiden on Sun, 05 Oct 2008 13:21:39 GMT]]></title><description><![CDATA[<p>Um von einem Fenster ein Screenshot zu machen, wollte ich folgenden befehl nutzen:</p>
<pre><code class="language-cpp">BitBlt( hdcTemp, 0, 0, 1024, 768, hdcScreen, 0, 0, SRCCOPY );
</code></pre>
<p>Wie man im Code unten sehen kann, wird der Desktop benutzt nicht das Window.<br />
Welche Information von hier:<br />
<a href="http://imageshack.us" rel="nofollow">[img=http://img147.imageshack.us/img147/8283/winidnp2.png]</a><br />
muss ich mit hdcScreen wechseln?<br />
WinID3x ?</p>
<pre><code class="language-cpp">#include &lt;windows.h&gt;
#include &lt;string&gt;
#include &lt;iostream&gt;

using namespace std;

class CStellwerk
{
private:
    HWND m_hDesktop;
public:

    void MakeScreenshot(char SavePath[]);
    void SaveScreen(HWND pScreen, char Path[]);
};

void CStellwerk::MakeScreenshot(char SavePath[])
{
     m_hDesktop =  GetDesktopWindow();
     if(m_hDesktop == NULL)
     {
         exit(1);
     }
     SaveScreen(m_hDesktop,SavePath);
}

int main()
{
    CStellwerk Stellwerk;
    Stellwerk.MakeScreenshot(&quot;C:\\screen.bmp&quot;);

}

void CStellwerk::SaveScreen(HWND pScreen, char Path[])

      {

          HDC hdcScreen;

          HBITMAP hbmScreen;

          //---------------Bitmap Informationen

          BITMAPINFO infobmp;

          infobmp.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);

          infobmp.bmiHeader.biWidth = 1024;

          infobmp.bmiHeader.biHeight = 768;

          infobmp.bmiHeader.biPlanes = 1;

          infobmp.bmiHeader.biBitCount = 24;

          infobmp.bmiHeader.biCompression = 0;

          infobmp.bmiHeader.biSizeImage = 0;

          infobmp.bmiHeader.biXPelsPerMeter = 0;

          infobmp.bmiHeader.biYPelsPerMeter = 0;

          infobmp.bmiHeader.biClrUsed = 0;

          infobmp.bmiHeader.biClrImportant = 0;

          int* bitmap = new int[1024*768*3];

          BITMAPFILEHEADER bfheader;

          bfheader.bfType = 19778;

          bfheader.bfSize = sizeof(BITMAPFILEHEADER) + 1024*768*3 + sizeof(BITMAPINFOHEADER);

          bfheader.bfReserved1 = 0;

          bfheader.bfReserved2 = 0;

          bfheader.bfOffBits = sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER);

          //Bitmap -----------------------      Informationen

          hdcScreen = GetWindowDC(pScreen);

          hbmScreen = CreateCompatibleBitmap(hdcScreen,1024,768);

          // temporärer DC

          HDC hdcTemp = CreateCompatibleDC( hdcScreen );

          // Bitmap reinselektieren

          HBITMAP hbmOld = (HBITMAP)SelectObject( hdcTemp, hbmScreen );

          // Inhalt von Desktop übertragen

          BitBlt( hdcTemp, 0, 0, 1024, 768, hdcScreen, 0, 0, SRCCOPY );

          int iResult = GetDIBits(hdcTemp,hbmScreen,0,768,bitmap,&amp;infobmp,DIB_RGB_COLORS);

          // aufräumen

          SelectObject( hdcTemp, hbmOld );

          DeleteObject( hbmScreen );

          DeleteDC( hdcTemp );
          HANDLE hfile = CreateFile( Path,GENERIC_WRITE,0,0,OPEN_ALWAYS,0,0);

          //Datei Schreiben

          DWORD word;
        WriteFile(hfile,&amp;bfheader,14,&amp;word,NULL);

          WriteFile(hfile,&amp;infobmp,40,&amp;word,NULL);

          WriteFile(hfile,bitmap,1024*768*3,&amp;word,NULL);

          ReleaseDC(pScreen,hdcScreen);

          CloseHandle(hfile);

          delete[] bitmap;

      }
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1593702</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1593702</guid><dc:creator><![CDATA[plshelp]]></dc:creator><pubDate>Sun, 05 Oct 2008 13:21:39 GMT</pubDate></item><item><title><![CDATA[Reply to Screen von Fenster und teil rausschneiden on Sun, 05 Oct 2008 13:23:28 GMT]]></title><description><![CDATA[<p><a href="http://img147.imageshack.us/my.php?image=winidnp2.png" rel="nofollow">hier nochmals der link</a></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1593703</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1593703</guid><dc:creator><![CDATA[plshelp]]></dc:creator><pubDate>Sun, 05 Oct 2008 13:23:28 GMT</pubDate></item><item><title><![CDATA[Reply to Screen von Fenster und teil rausschneiden on Sun, 05 Oct 2008 13:30:19 GMT]]></title><description><![CDATA[<p>Auf Codeeproject gibt es dazu tonnenweise fertigen Code.<br />
Z.B.:<br />
<a href="http://www.codeproject.com/KB/dialog/windowsnapshot.aspx" rel="nofollow">http://www.codeproject.com/KB/dialog/windowsnapshot.aspx</a><br />
<a href="http://www.codeproject.com/KB/graphics/screencapture.aspx" rel="nofollow">http://www.codeproject.com/KB/graphics/screencapture.aspx</a></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1593705</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1593705</guid><dc:creator><![CDATA[Martin Richter]]></dc:creator><pubDate>Sun, 05 Oct 2008 13:30:19 GMT</pubDate></item><item><title><![CDATA[Reply to Screen von Fenster und teil rausschneiden on Sun, 05 Oct 2008 18:28:15 GMT]]></title><description><![CDATA[<p>danke, leider aber bedient sich der code von headern die man nur bei der MFC mitbekommt. Diese besitze ich nicht und will es auch nicht extra kaufen.</p>
<p>Ich denke aber auch, dass mein code sehr nah an der lösung ist. Ich habe ja nun den window handle (FindWindow()), weiß nur nicht, wo ich diesen nun einsetzen muss, damit der code dieses fenster für den screenshot nutzt.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1593835</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1593835</guid><dc:creator><![CDATA[plshelp]]></dc:creator><pubDate>Sun, 05 Oct 2008 18:28:15 GMT</pubDate></item><item><title><![CDATA[Reply to Screen von Fenster und teil rausschneiden on Sun, 05 Oct 2008 19:17:27 GMT]]></title><description><![CDATA[<p>Ob der Code nun die MFC bedient oder nicht. Das Prinzip ist das selbe. Zudem heißen die meisten Funktionen in der MFC exakt wie Ihre WinAPI-Originale.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1593852</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1593852</guid><dc:creator><![CDATA[Martin Richter]]></dc:creator><pubDate>Sun, 05 Oct 2008 19:17:27 GMT</pubDate></item><item><title><![CDATA[Reply to Screen von Fenster und teil rausschneiden on Mon, 06 Oct 2008 01:02:01 GMT]]></title><description><![CDATA[<p>BitBlt() nimmt nen HDC, du hast nen HWND.<br />
<a href="http://msdn.microsoft.com/en-us/library/ms533241(VS.85).aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/ms533241(VS.85).aspx</a></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1593947</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1593947</guid><dc:creator><![CDATA[geeky]]></dc:creator><pubDate>Mon, 06 Oct 2008 01:02:01 GMT</pubDate></item><item><title><![CDATA[Reply to Screen von Fenster und teil rausschneiden on Mon, 06 Oct 2008 09:24:02 GMT]]></title><description><![CDATA[<p>In Zeile 100 lautet BitBlt():</p>
<pre><code class="language-cpp">BitBlt( hdcTemp, 0, 0, 1024, 768, hdcScreen, 0, 0, SRCCOPY );
</code></pre>
<p>Wo ist da ein HWND? Ich meine, hdcTemp und hdcScreen nutzt HDC.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1594064</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1594064</guid><dc:creator><![CDATA[plshelp]]></dc:creator><pubDate>Mon, 06 Oct 2008 09:24:02 GMT</pubDate></item><item><title><![CDATA[Reply to Screen von Fenster und teil rausschneiden on Mon, 06 Oct 2008 17:50:17 GMT]]></title><description><![CDATA[<p>plshelp schrieb:</p>
<blockquote>
<p>Ich habe ja nun den window handle (FindWindow())[..]</p>
</blockquote>
<p>Da hast du dein HWND und wie du schon bemerkt hast brauchst du bei BitBlt() ein HDC.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1594400</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1594400</guid><dc:creator><![CDATA[geeky]]></dc:creator><pubDate>Mon, 06 Oct 2008 17:50:17 GMT</pubDate></item></channel></rss>