<?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[Was machen ich bei diesen Screenshot code falsch !?]]></title><description><![CDATA[<p>jemand eine idee was ich da Falsch mache. er erstellt mir eine 2 MB große datei<br />
leider ist da kein screeshot drin. Sondern wenn ich die bmp datei öffen will geht es nicht da irgendwie nix drin ist. Jemand eine idee !?</p>
<pre><code class="language-cpp">int main(void)
{
   int width = 1024;;
   int height = 768;
   HDC hdc;
   HWND hWnd;
   hdc=GetWindowDC(GetForegroundWindow());

   dc2bitmap(hdc, width, height);

   getch();
   return 0;
}
int dc2bitmap(HDC hdc, int width, int height)
{
   char filename[] = &quot;fsdfsdf.bmp&quot; ;

    HDC hdc2;
    HBITMAP aBmp;
    BITMAPINFO bi;
    HGDIOBJ OldObj;
    void *dibvalues;
    HANDLE fileHandle;

    BITMAPFILEHEADER bmfh;
    BITMAPINFOHEADER bmih;
        DWORD bytes_write;
    DWORD bytes_written;

    hdc2=CreateCompatibleDC(hdc);

    ZeroMemory(&amp;bmih,sizeof(BITMAPINFOHEADER));
    bmih.biSize=sizeof(BITMAPINFOHEADER);
      bmih.biHeight=height;
        bmih.biWidth=width;
        bmih.biPlanes=1;
        bmih.biBitCount=24;
    bmih.biCompression=BI_RGB;
    bmih.biSizeImage = ((((bmih.biWidth * bmih.biBitCount) + 31) &amp; ~31) &gt;&gt; 3) * bmih.biHeight;
        bmih.biXPelsPerMeter = 0;
        bmih.biYPelsPerMeter = 0;
        bmih.biClrImportant = 0;
    //bmih.biSizeImage=(3*bmih.biHeight*bmih.biWidth);
        //bmih.biSizeImage = 0; 

    bi.bmiHeader=bmih;

    aBmp=CreateDIBSection(hdc,&amp;bi,DIB_RGB_COLORS,(void**)&amp;dibvalues,NULL,NULL);

    if (aBmp==NULL)
    {
        OutputDebugString(&quot;CreateDIBSection failed!\n&quot;);
        return 0;
    }

    OldObj=SelectObject(hdc2,aBmp);
    BitBlt(hdc2,0,0,width,height,hdc,0,0,SRCCOPY);

    ZeroMemory(&amp;bmfh,sizeof(BITMAPFILEHEADER));
    bmfh.bfOffBits=sizeof(BITMAPFILEHEADER)+sizeof(BITMAPINFOHEADER);
    bmfh.bfSize=(3*bmih.biHeight*bmih.biWidth)+sizeof(BITMAPFILEHEADER)+sizeof(BITMAPINFOHEADER);
    bmfh.bfType=0x4d42;
        bmfh.bfReserved1 = 0;
        bmfh.bfReserved2 = 0;

    fileHandle=CreateFile(filename,GENERIC_READ | GENERIC_WRITE,(DWORD)0,NULL,
                                                    CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL,(HANDLE) NULL);
    if (fileHandle==INVALID_HANDLE_VALUE)
    {
        OutputDebugString(&quot;CreateFile failed!\n&quot;);
        return 0;
    }

        // Write the BITMAPFILEHEADER
        bytes_write=sizeof(BITMAPFILEHEADER);
    if (!WriteFile(fileHandle,(void*)&amp;bmfh,bytes_write,&amp;bytes_written,NULL))
    {
        OutputDebugString(&quot;WriteFile failed!\n&quot;);
        return 0;
    }

        //Write the BITMAPINFOHEADER
    bytes_write=sizeof(BITMAPINFOHEADER);
    if (!WriteFile(fileHandle,(void*)&amp;bmih,bytes_write,&amp;bytes_written,NULL))
    {
        OutputDebugString(&quot;WriteFile failed!\n&quot;);
        return 0;
    }

        //Write the Color Index Array???
        bytes_write=bmih.biSizeImage;//3*bmih.biHeight*bmih.biWidth;
    if (!WriteFile(fileHandle,(void*)dibvalues,bytes_write,&amp;bytes_written,NULL))
    {
        OutputDebugString(&quot;WriteFile failed!\n&quot;);
        return 0;
    }

    CloseHandle(fileHandle);

    DeleteObject(SelectObject(hdc2,OldObj));
    DeleteDC(hdc2);

    return 1;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/topic/142984/was-machen-ich-bei-diesen-screenshot-code-falsch</link><generator>RSS for Node</generator><lastBuildDate>Wed, 15 Jul 2026 00:30:39 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/142984.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 04 Apr 2006 18:21:24 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Was machen ich bei diesen Screenshot code falsch !? on Tue, 04 Apr 2006 18:21:24 GMT]]></title><description><![CDATA[<p>jemand eine idee was ich da Falsch mache. er erstellt mir eine 2 MB große datei<br />
leider ist da kein screeshot drin. Sondern wenn ich die bmp datei öffen will geht es nicht da irgendwie nix drin ist. Jemand eine idee !?</p>
<pre><code class="language-cpp">int main(void)
{
   int width = 1024;;
   int height = 768;
   HDC hdc;
   HWND hWnd;
   hdc=GetWindowDC(GetForegroundWindow());

   dc2bitmap(hdc, width, height);

   getch();
   return 0;
}
int dc2bitmap(HDC hdc, int width, int height)
{
   char filename[] = &quot;fsdfsdf.bmp&quot; ;

    HDC hdc2;
    HBITMAP aBmp;
    BITMAPINFO bi;
    HGDIOBJ OldObj;
    void *dibvalues;
    HANDLE fileHandle;

    BITMAPFILEHEADER bmfh;
    BITMAPINFOHEADER bmih;
        DWORD bytes_write;
    DWORD bytes_written;

    hdc2=CreateCompatibleDC(hdc);

    ZeroMemory(&amp;bmih,sizeof(BITMAPINFOHEADER));
    bmih.biSize=sizeof(BITMAPINFOHEADER);
      bmih.biHeight=height;
        bmih.biWidth=width;
        bmih.biPlanes=1;
        bmih.biBitCount=24;
    bmih.biCompression=BI_RGB;
    bmih.biSizeImage = ((((bmih.biWidth * bmih.biBitCount) + 31) &amp; ~31) &gt;&gt; 3) * bmih.biHeight;
        bmih.biXPelsPerMeter = 0;
        bmih.biYPelsPerMeter = 0;
        bmih.biClrImportant = 0;
    //bmih.biSizeImage=(3*bmih.biHeight*bmih.biWidth);
        //bmih.biSizeImage = 0; 

    bi.bmiHeader=bmih;

    aBmp=CreateDIBSection(hdc,&amp;bi,DIB_RGB_COLORS,(void**)&amp;dibvalues,NULL,NULL);

    if (aBmp==NULL)
    {
        OutputDebugString(&quot;CreateDIBSection failed!\n&quot;);
        return 0;
    }

    OldObj=SelectObject(hdc2,aBmp);
    BitBlt(hdc2,0,0,width,height,hdc,0,0,SRCCOPY);

    ZeroMemory(&amp;bmfh,sizeof(BITMAPFILEHEADER));
    bmfh.bfOffBits=sizeof(BITMAPFILEHEADER)+sizeof(BITMAPINFOHEADER);
    bmfh.bfSize=(3*bmih.biHeight*bmih.biWidth)+sizeof(BITMAPFILEHEADER)+sizeof(BITMAPINFOHEADER);
    bmfh.bfType=0x4d42;
        bmfh.bfReserved1 = 0;
        bmfh.bfReserved2 = 0;

    fileHandle=CreateFile(filename,GENERIC_READ | GENERIC_WRITE,(DWORD)0,NULL,
                                                    CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL,(HANDLE) NULL);
    if (fileHandle==INVALID_HANDLE_VALUE)
    {
        OutputDebugString(&quot;CreateFile failed!\n&quot;);
        return 0;
    }

        // Write the BITMAPFILEHEADER
        bytes_write=sizeof(BITMAPFILEHEADER);
    if (!WriteFile(fileHandle,(void*)&amp;bmfh,bytes_write,&amp;bytes_written,NULL))
    {
        OutputDebugString(&quot;WriteFile failed!\n&quot;);
        return 0;
    }

        //Write the BITMAPINFOHEADER
    bytes_write=sizeof(BITMAPINFOHEADER);
    if (!WriteFile(fileHandle,(void*)&amp;bmih,bytes_write,&amp;bytes_written,NULL))
    {
        OutputDebugString(&quot;WriteFile failed!\n&quot;);
        return 0;
    }

        //Write the Color Index Array???
        bytes_write=bmih.biSizeImage;//3*bmih.biHeight*bmih.biWidth;
    if (!WriteFile(fileHandle,(void*)dibvalues,bytes_write,&amp;bytes_written,NULL))
    {
        OutputDebugString(&quot;WriteFile failed!\n&quot;);
        return 0;
    }

    CloseHandle(fileHandle);

    DeleteObject(SelectObject(hdc2,OldObj));
    DeleteDC(hdc2);

    return 1;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1030528</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1030528</guid><dc:creator><![CDATA[screen]]></dc:creator><pubDate>Tue, 04 Apr 2006 18:21:24 GMT</pubDate></item><item><title><![CDATA[Reply to Was machen ich bei diesen Screenshot code falsch !? on Tue, 04 Apr 2006 20:07:20 GMT]]></title><description><![CDATA[<p>Habe das mal geteste bei mit tut es das gleich finde da aber auch nix !! Vielleicht finde ja jemand von ecuhw as darin !!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1030611</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1030611</guid><dc:creator><![CDATA[tester2]]></dc:creator><pubDate>Tue, 04 Apr 2006 20:07:20 GMT</pubDate></item><item><title><![CDATA[Reply to Was machen ich bei diesen Screenshot code falsch !? on Wed, 05 Apr 2006 09:50:49 GMT]]></title><description><![CDATA[<p>komisch, bei mir funktioniert es...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1030852</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1030852</guid><dc:creator><![CDATA[Airdamn]]></dc:creator><pubDate>Wed, 05 Apr 2006 09:50:49 GMT</pubDate></item><item><title><![CDATA[Reply to Was machen ich bei diesen Screenshot code falsch !? on Wed, 05 Apr 2006 12:51:53 GMT]]></title><description><![CDATA[<p>Hast du vieleicht in Windows eine andere Auflösung oder Farbtiefe eingestellt, als 1024 * 768 true color ?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1031045</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1031045</guid><dc:creator><![CDATA[MisterX]]></dc:creator><pubDate>Wed, 05 Apr 2006 12:51:53 GMT</pubDate></item><item><title><![CDATA[Reply to Was machen ich bei diesen Screenshot code falsch !? on Wed, 05 Apr 2006 12:55:16 GMT]]></title><description><![CDATA[<p>Ist zwar nicht der eventuelle Fehler, aber warum definierst du in main</p>
<pre><code class="language-cpp">HWND hWnd;
</code></pre>
<p>wenn du es nicht verwendest?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1031046</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1031046</guid><dc:creator><![CDATA[Antwort]]></dc:creator><pubDate>Wed, 05 Apr 2006 12:55:16 GMT</pubDate></item><item><title><![CDATA[Reply to Was machen ich bei diesen Screenshot code falsch !? on Wed, 05 Apr 2006 12:59:47 GMT]]></title><description><![CDATA[<p>Was bedeutet denn</p>
<blockquote>
<p>Sondern wenn ich die bmp datei öffen will geht es nicht da irgendwie nix drin ist.</p>
</blockquote>
<p>Stürzt es beim offnen ab?<br />
Gibt es ne Fehlermeldung?</p>
<p>Oder ist &quot;nix drin&quot; einfach schwarz?<br />
Wenn ja, machst du möglicherweise ein Bild der eigenen DosBox in dem das Programm ausgeführt wird, da diese ja im Moment des Screenshot ja im Vordergrund ist.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1031053</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1031053</guid><dc:creator><![CDATA[Maik 007]]></dc:creator><pubDate>Wed, 05 Apr 2006 12:59:47 GMT</pubDate></item></channel></rss>