<?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 scrollen - problem]]></title><description><![CDATA[<p>hi Leute<br />
Ich habe in meinem Hauptfenster ein Childfenster (&quot;Scroller&quot;), das mit Scrollbars ausgestattet ist. Ich blitte das Bild dort hinein (BitBlt) und scrolle herum.</p>
<p>Problem:<br />
- Beim Scrollen flackert es, aber: nur im Bereich, der am Anfang ins Fenster passt.<br />
D.h. wenn das Fenster die Grösse 400x300 hat, dann flackert beim Scrollen nur die 400x300px links oben, der Rest wird schön gescrollt.</p>
<p>Aufbau: (ich benutze die SimpleWndClassIV von <a href="http://www.foosyerdoos.fsnet.co.uk/MainFiles/DynaContainFiles/Code/SimpleWndClass04.html" rel="nofollow">FoosYerDoos</a>)</p>
<p><strong>HauptFenster (hAppWnd)</strong></p>
<pre><code class="language-cpp">BOOL CppAppWnd::OnCreate(CREATESTRUCT *cs)
{
    // ..
    hScroll = CreateWindow( &quot;Scroller&quot;, NULL,
                     WS_CHILD | WS_BORDER | WS_VISIBLE | WS_HSCROLL | WS_VSCROLL,
                     0,0,0,0, hAppWnd, NULL, hInst, NULL);
    // ..
}
</code></pre>
<p><strong>ScrollFenster (hScroll)</strong></p>
<pre><code class="language-cpp">BOOL CScrollWnd::OnSize(LPARAM lParam)
{
    // Grösse des Fensters und maximale Scrollpositionen berechnen
    xMapScroll = LOWORD(lParam);
    yMapScroll = HIWORD(lParam);
    xMax = xBmp - xMapScroll + iRand;  // Bildbreite - Anzeigebreite + Scrollbar
    yMax = yBmp - yMapScroll + iRand; // Bildhöhe - Anzeigehöhe + Scrollbar 

    // nun noch die daten in der ScollInfo ändern und setzen  
    si.cbSize = sizeof(si);
    si.fMask  = SIF_RANGE | SIF_POS;
    si.nMin   = 0;
    si.nMax   = xMax; // Bildbreite - Anzeigebreite + Scrollbar
    si.nPos   = xPos; // vorherige Scrollposition beibehalten
    SetScrollInfo(hScroll, SB_HORZ, &amp;si, TRUE);
    si.nMax   = yMax;
    si.nPos   = yPos; // vorherige Scrollposition beibehalten
    SetScrollInfo(hScroll, SB_VERT, &amp;si, TRUE);
    UpdateWindow(hScroll);
return 0;
}
//----------
BOOL CScrollWnd::OnPaint()
{ 
InvalidateRect(hScroll,NULL,true);
PAINTSTRUCT ps;
HDC hdc = BeginPaint(hScroll, &amp;ps);
HDC hdcMem = CreateCompatibleDC(NULL);

// Male das bitmap ins Map-Feld
SelectObject(hdcMem, hBmp);
BitBlt(hdc, 0, 0, xMapScroll, yMapScroll, hdcMem, xPos, yPos, SRCCOPY);

DeleteDC(hdcMem);
EndPaint(hScroll, &amp;ps);

return 0;
}
//----------
BOOL CScrollWnd::OnHScroll(WPARAM wParam)
{
    int xBackup = xPos;
     //nun ermitteln wir die H-Position, bzw. setzen diese 
     switch (LOWORD(wParam)) 
     { 
         case SB_PAGEUP: 
             xPos = xPos - 50; 
             break; 
         case SB_PAGEDOWN: 
             xPos = xPos + 50; 
             break; 
         case SB_LINEUP: 
             xPos = xPos - 5; 
             break; 
         case SB_LINEDOWN: 
             xPos = xPos + 5; 
             break; 
         case SB_THUMBPOSITION: 
             xPos = HIWORD(wParam); 
             break;
         case SB_THUMBTRACK: 
             xPos = HIWORD(wParam); 
             break;
         default: 
             xPos = xPos;
     }
     // prüfen ob nicht kleiner 0 
     if (xPos &lt; 0) xPos = 0;
     // und nicht größer maximale Scrollposition
     if (xPos &gt; xMax) xPos = xMax;

     if (xBackup != xPos) //falls sich etwas verändert hat
     {
     // nun noch die daten in der ScollInfo ändern und setzen  
     si.cbSize = sizeof(si);
     si.fMask  = SIF_POS | SIF_DISABLENOSCROLL;
     si.nPos   = xPos;
     SetScrollInfo(hScroll, SB_HORZ, &amp;si, TRUE);
     // Window schieben 
     ScrollWindowEx(hScroll, -xPos, -yPos, (CONST RECT *) NULL, 
         (CONST RECT *) NULL, (HRGN) NULL, (LPRECT) NULL, SW_INVALIDATE); 
     UpdateWindow(hScroll);
     }       

return 0;
}
// dito für VSCROLL
</code></pre>
<p>Ach ja.. die Frage: Wieso tritt der oben genannten Fehler auf und wie kann ich ihn beheben?<br />
Vielen Dank im Voraus</p>
<p>[Den kompletten Quellcode findet sich unter: <a href="http://ultinate.100free.com/Debugging/sourcecode_all.htm" rel="nofollow">http://ultinate.100free.com/Debugging/sourcecode_all.htm</a>]</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/93238/bitmap-scrollen-problem</link><generator>RSS for Node</generator><lastBuildDate>Fri, 24 Apr 2026 23:46:49 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/93238.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 27 Nov 2004 16:36:24 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Bitmap scrollen - problem on Tue, 30 Nov 2004 21:24:06 GMT]]></title><description><![CDATA[<p>hi Leute<br />
Ich habe in meinem Hauptfenster ein Childfenster (&quot;Scroller&quot;), das mit Scrollbars ausgestattet ist. Ich blitte das Bild dort hinein (BitBlt) und scrolle herum.</p>
<p>Problem:<br />
- Beim Scrollen flackert es, aber: nur im Bereich, der am Anfang ins Fenster passt.<br />
D.h. wenn das Fenster die Grösse 400x300 hat, dann flackert beim Scrollen nur die 400x300px links oben, der Rest wird schön gescrollt.</p>
<p>Aufbau: (ich benutze die SimpleWndClassIV von <a href="http://www.foosyerdoos.fsnet.co.uk/MainFiles/DynaContainFiles/Code/SimpleWndClass04.html" rel="nofollow">FoosYerDoos</a>)</p>
<p><strong>HauptFenster (hAppWnd)</strong></p>
<pre><code class="language-cpp">BOOL CppAppWnd::OnCreate(CREATESTRUCT *cs)
{
    // ..
    hScroll = CreateWindow( &quot;Scroller&quot;, NULL,
                     WS_CHILD | WS_BORDER | WS_VISIBLE | WS_HSCROLL | WS_VSCROLL,
                     0,0,0,0, hAppWnd, NULL, hInst, NULL);
    // ..
}
</code></pre>
<p><strong>ScrollFenster (hScroll)</strong></p>
<pre><code class="language-cpp">BOOL CScrollWnd::OnSize(LPARAM lParam)
{
    // Grösse des Fensters und maximale Scrollpositionen berechnen
    xMapScroll = LOWORD(lParam);
    yMapScroll = HIWORD(lParam);
    xMax = xBmp - xMapScroll + iRand;  // Bildbreite - Anzeigebreite + Scrollbar
    yMax = yBmp - yMapScroll + iRand; // Bildhöhe - Anzeigehöhe + Scrollbar 

    // nun noch die daten in der ScollInfo ändern und setzen  
    si.cbSize = sizeof(si);
    si.fMask  = SIF_RANGE | SIF_POS;
    si.nMin   = 0;
    si.nMax   = xMax; // Bildbreite - Anzeigebreite + Scrollbar
    si.nPos   = xPos; // vorherige Scrollposition beibehalten
    SetScrollInfo(hScroll, SB_HORZ, &amp;si, TRUE);
    si.nMax   = yMax;
    si.nPos   = yPos; // vorherige Scrollposition beibehalten
    SetScrollInfo(hScroll, SB_VERT, &amp;si, TRUE);
    UpdateWindow(hScroll);
return 0;
}
//----------
BOOL CScrollWnd::OnPaint()
{ 
InvalidateRect(hScroll,NULL,true);
PAINTSTRUCT ps;
HDC hdc = BeginPaint(hScroll, &amp;ps);
HDC hdcMem = CreateCompatibleDC(NULL);

// Male das bitmap ins Map-Feld
SelectObject(hdcMem, hBmp);
BitBlt(hdc, 0, 0, xMapScroll, yMapScroll, hdcMem, xPos, yPos, SRCCOPY);

DeleteDC(hdcMem);
EndPaint(hScroll, &amp;ps);

return 0;
}
//----------
BOOL CScrollWnd::OnHScroll(WPARAM wParam)
{
    int xBackup = xPos;
     //nun ermitteln wir die H-Position, bzw. setzen diese 
     switch (LOWORD(wParam)) 
     { 
         case SB_PAGEUP: 
             xPos = xPos - 50; 
             break; 
         case SB_PAGEDOWN: 
             xPos = xPos + 50; 
             break; 
         case SB_LINEUP: 
             xPos = xPos - 5; 
             break; 
         case SB_LINEDOWN: 
             xPos = xPos + 5; 
             break; 
         case SB_THUMBPOSITION: 
             xPos = HIWORD(wParam); 
             break;
         case SB_THUMBTRACK: 
             xPos = HIWORD(wParam); 
             break;
         default: 
             xPos = xPos;
     }
     // prüfen ob nicht kleiner 0 
     if (xPos &lt; 0) xPos = 0;
     // und nicht größer maximale Scrollposition
     if (xPos &gt; xMax) xPos = xMax;

     if (xBackup != xPos) //falls sich etwas verändert hat
     {
     // nun noch die daten in der ScollInfo ändern und setzen  
     si.cbSize = sizeof(si);
     si.fMask  = SIF_POS | SIF_DISABLENOSCROLL;
     si.nPos   = xPos;
     SetScrollInfo(hScroll, SB_HORZ, &amp;si, TRUE);
     // Window schieben 
     ScrollWindowEx(hScroll, -xPos, -yPos, (CONST RECT *) NULL, 
         (CONST RECT *) NULL, (HRGN) NULL, (LPRECT) NULL, SW_INVALIDATE); 
     UpdateWindow(hScroll);
     }       

return 0;
}
// dito für VSCROLL
</code></pre>
<p>Ach ja.. die Frage: Wieso tritt der oben genannten Fehler auf und wie kann ich ihn beheben?<br />
Vielen Dank im Voraus</p>
<p>[Den kompletten Quellcode findet sich unter: <a href="http://ultinate.100free.com/Debugging/sourcecode_all.htm" rel="nofollow">http://ultinate.100free.com/Debugging/sourcecode_all.htm</a>]</p>
]]></description><link>https://www.c-plusplus.net/forum/post/660620</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/660620</guid><dc:creator><![CDATA[nate7]]></dc:creator><pubDate>Tue, 30 Nov 2004 21:24:06 GMT</pubDate></item><item><title><![CDATA[Reply to Bitmap scrollen - problem on Sat, 27 Nov 2004 18:07:41 GMT]]></title><description><![CDATA[<p>was mir so auffällt: bei BildFenster (hMap):<br />
InvalidateRect in der onpaint routine?<br />
Weiterhin benutze ich immer GetDC umd die aktuelle hDC zu bekommen (nachher natürlich ReleaseDC um die wieder freizugeben).Ok, ich arbeite auch sonst mit &quot;original&quot; windowsnachrichten (also anstatt onpaint ein WM_PAINT <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /> und da sind als behandlungsroutine drin erstmals ein BeginPaint und EndPaint und danach erst die eigentliche zeichnungsroutine: GetClientRect,<br />
GetDC,<br />
CreateCompatibleDC,<br />
StretchBlt,<br />
DeleteDC,(=&gt;compatibleDC)<br />
ReleaseDC<br />
vielleicht etwas umständlch, funktioniert aber ohne probleme (einsatz in einem Skinmaker =&gt;zoomen und objekte positionieren)</p>
]]></description><link>https://www.c-plusplus.net/forum/post/660685</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/660685</guid><dc:creator><![CDATA[CDW]]></dc:creator><pubDate>Sat, 27 Nov 2004 18:07:41 GMT</pubDate></item><item><title><![CDATA[Reply to Bitmap scrollen - problem on Sun, 28 Nov 2004 20:09:27 GMT]]></title><description><![CDATA[<p>- InvalidateRect: falsch, oder einfach nur unnötig?</p>
<p>- das mit dem OnPaint() ist ja nur kosmetik.. <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>- naja.. die methode mit BeginPaint und EndPaint müsste ja auch funktionieren.<br />
ich vermute, dass das problem irgendwo im OnHScroll() drin steckt.. den teil hab ich nämlich geklaut (<a href="http://www.c-plusplus.net/forum/viewtopic.php?t=89773" rel="nofollow">http://www.c-plusplus.net/forum/viewtopic.php?t=89773</a>) *schäm* <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>
]]></description><link>https://www.c-plusplus.net/forum/post/660821</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/660821</guid><dc:creator><![CDATA[nate7]]></dc:creator><pubDate>Sun, 28 Nov 2004 20:09:27 GMT</pubDate></item></channel></rss>