<?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[BitBlt mit anschließendem Rectangle geht nicht]]></title><description><![CDATA[<p>Hallo!</p>
<p>Ich habe ein schnuckeliges Programm, welches mir brav einen Screenshot vom Desktop anzeigt. Jetzt soll der Benutzer dort einen Rechteckigen Bereich malen, mit dem das Programm dann was weiter macht...</p>
<p>Ich hab erstmal leicht angefangen und wollte in meinen Screenshot einfach ein Rechteck dazumalen, ich sehs nur leider nicht <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f61e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--disappointed_face"
      title=":("
      alt="😞"
    /></p>
<pre><code>void OnPaint(HWND hwnd) {
        HDC hBitmapdc, hWindowdc;
        HBITMAP hOld;
        PAINTSTRUCT ps;
        RECT rc;

        // If the bitmap is present, draw it
        if (hDesktopBitmap_) {
            // Get window dc and start paint
            hWindowdc = BeginPaint(hwnd, &amp;ps);
            hWindowdc = GetDC(hwnd);
            // Create compatible dc
            hBitmapdc = CreateCompatibleDC(hWindowdc);
            // Select the bitmap into the dc
            hOld = SelectBitmap(hBitmapdc, hDesktopBitmap_);
            // Get width and height of this window
            GetClientRect(hwnd, &amp;rc);
            // Draw the bitmap to the window leaving a border of 20 pixels
            BitBlt(hWindowdc, 0, 0, rc.right, rc.bottom,
                   hBitmapdc, 0, 0, SRCCOPY);
            // draw a rectangle
            RECT rectangle;
            HBRUSH hBrush;
            Rectangle(hWindowdc, 100, 100, 100, 100);
            hBrush = CreateSolidBrush(RGB(255,0,0)) ;
            FillRect (hWindowdc, &amp;rectangle, hBrush) ;
            // Delete bitmap dc
            DeleteDC(hBitmapdc);
            // Tell windows that you've updated the window
            EndPaint(hwnd, &amp;ps);
        }
}
</code></pre>
<p>Wie gesagt, der Screenshot wird angezeigt, BitBlt tut also seine Arbeit, aber das Rechteck ist nicht sichtbar. <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f615.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--confused_face"
      title=":confused:"
      alt="😕"
    /></p>
<p>Kann mir da einer helfen?</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/243319/bitblt-mit-anschließendem-rectangle-geht-nicht</link><generator>RSS for Node</generator><lastBuildDate>Sat, 04 Apr 2026 03:29:37 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/243319.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 15 Jun 2009 14:14:00 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to BitBlt mit anschließendem Rectangle geht nicht on Mon, 15 Jun 2009 14:14:00 GMT]]></title><description><![CDATA[<p>Hallo!</p>
<p>Ich habe ein schnuckeliges Programm, welches mir brav einen Screenshot vom Desktop anzeigt. Jetzt soll der Benutzer dort einen Rechteckigen Bereich malen, mit dem das Programm dann was weiter macht...</p>
<p>Ich hab erstmal leicht angefangen und wollte in meinen Screenshot einfach ein Rechteck dazumalen, ich sehs nur leider nicht <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f61e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--disappointed_face"
      title=":("
      alt="😞"
    /></p>
<pre><code>void OnPaint(HWND hwnd) {
        HDC hBitmapdc, hWindowdc;
        HBITMAP hOld;
        PAINTSTRUCT ps;
        RECT rc;

        // If the bitmap is present, draw it
        if (hDesktopBitmap_) {
            // Get window dc and start paint
            hWindowdc = BeginPaint(hwnd, &amp;ps);
            hWindowdc = GetDC(hwnd);
            // Create compatible dc
            hBitmapdc = CreateCompatibleDC(hWindowdc);
            // Select the bitmap into the dc
            hOld = SelectBitmap(hBitmapdc, hDesktopBitmap_);
            // Get width and height of this window
            GetClientRect(hwnd, &amp;rc);
            // Draw the bitmap to the window leaving a border of 20 pixels
            BitBlt(hWindowdc, 0, 0, rc.right, rc.bottom,
                   hBitmapdc, 0, 0, SRCCOPY);
            // draw a rectangle
            RECT rectangle;
            HBRUSH hBrush;
            Rectangle(hWindowdc, 100, 100, 100, 100);
            hBrush = CreateSolidBrush(RGB(255,0,0)) ;
            FillRect (hWindowdc, &amp;rectangle, hBrush) ;
            // Delete bitmap dc
            DeleteDC(hBitmapdc);
            // Tell windows that you've updated the window
            EndPaint(hwnd, &amp;ps);
        }
}
</code></pre>
<p>Wie gesagt, der Screenshot wird angezeigt, BitBlt tut also seine Arbeit, aber das Rechteck ist nicht sichtbar. <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f615.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--confused_face"
      title=":confused:"
      alt="😕"
    /></p>
<p>Kann mir da einer helfen?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1727012</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1727012</guid><dc:creator><![CDATA[quaid]]></dc:creator><pubDate>Mon, 15 Jun 2009 14:14:00 GMT</pubDate></item><item><title><![CDATA[Reply to BitBlt mit anschließendem Rectangle geht nicht on Mon, 15 Jun 2009 14:56:10 GMT]]></title><description><![CDATA[<p>Hallo!<br />
Hint:</p>
<pre><code class="language-cpp">BOOL Rectangle(hc, Left, Top, Right, Bottom);
</code></pre>
<p>Du rufst Rectangle mit NULL-rect auf, FillRect mit rectangle=müll.</p>
<p>Wozu GetDC (ohne ReleaseDC), wo ist DeleteObject(hBrush), und dazu auch SelectObject(hWindowdc, hOld) fehlt.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1727043</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1727043</guid><dc:creator><![CDATA[sapero]]></dc:creator><pubDate>Mon, 15 Jun 2009 14:56:10 GMT</pubDate></item><item><title><![CDATA[Reply to BitBlt mit anschließendem Rectangle geht nicht on Wed, 17 Jun 2009 12:56:56 GMT]]></title><description><![CDATA[<p>Jetzt hab ichs gecheckt. Für alle dies interessiert, hier der Code:</p>
<pre><code>void OnPaint(HWND hwnd) {
        HDC hBitmapdc, hWindowdc;
        HBITMAP hOld;
        PAINTSTRUCT ps;
        RECT rc;

        // If the bitmap is present, draw it
        if (hDesktopBitmap_) {
            // Get window dc and start paint
            hWindowdc = BeginPaint(hwnd, &amp;ps);
            hWindowdc = GetDC(hwnd);
            // Create compatible dc
            hBitmapdc = CreateCompatibleDC(hWindowdc);
            // Select the bitmap into the dc
            hOld = SelectBitmap(hBitmapdc, hDesktopBitmap_);
            SelectObject(hWindowdc, hOld);
            // Get width and height of this window
            GetClientRect(hwnd, &amp;rc);
            // Draw the bitmap to the window leaving a border of 20 pixels
            BitBlt(hWindowdc, 0, 0, rc.right, rc.bottom,
                   hBitmapdc, 0, 0, SRCCOPY);
            // draw a rectangle
            RECT rectangle;
            HBRUSH hBrush;
          	rectangle.left = 100;
          	rectangle.top = 100;
          	rectangle.bottom = 300;
          	rectangle.right = 600;
            hBrush = CreateSolidBrush(RGB(255,0,0)) ;
            FillRect (hWindowdc, &amp;rectangle, hBrush) ;
            // Delete bitmap dc
            DeleteDC(hBitmapdc);
            DeleteObject(hBrush);
            // Tell windows that you've updated the window
            EndPaint(hwnd, &amp;ps);
        }
}
</code></pre>
<p>Danke für den Tip!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1728158</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1728158</guid><dc:creator><![CDATA[quaid]]></dc:creator><pubDate>Wed, 17 Jun 2009 12:56:56 GMT</pubDate></item></channel></rss>