Best way of refreshing after scrolling

After scrolling an EDIT control that contains text and images I use this to refresh the window:
1
2
3
4
5
void refresh(HWND hwnd){
    RECT ControlWindowRect;
    GetWindowRect(hwnd, &ControlWindowRect);
    ::RedrawWindow(hwnd, &ControlWindowRect, NULL, RDW_UPDATENOW|RDW_ALLCHILDREN);
}


It follows the ScrollWindow() function
I don't get the expected result, the EDIT control's content, especially when I scroll very quickly, remains painted like a trace behind and I wonder if there's a good method that everyone uses to repaint the window after re-sizing or scrolling it. My function ahead also makes the window flash continuously as I am re-sizing it by dragging its borders.

Thanks for your ideas!
Last edited on
You should use InvalidateRect for force redraw.
My function looks like this now:
1
2
3
4
5
6
void refresh(HWND hwnd){
    RECT ControlWindowRect;
    ZeroMemory(&ControlWindowRect, sizeof(RECT));
    GetWindowRect(hwnd, &ControlWindowRect);
    InvalidateRect(hwnd, &ControlWindowRect, FALSE);
}


The window doesn't flash anymore when is being re-sized but the scrolling problems persists. When I scroll upward it seems like the part of the content that should be hidden away is not. It is moved out of the scrolling area and painted above other content of the window. When I re-size it a little bit, everything is re-painted well. So, when I use this function inside WM_SIZE it works. When I use it with WM_VSCROLL it does not.

The window (an EDIT control) I want to scroll is contained by a STATIC control, owned by the window. The EDIT control is sub-classed, and the WM_VSCROLL is handled inside its own procedure. The EDIT control contains other STATIC controls with text and images. Maybe this will give clues, too.
Last edited on
Could the problem lie here?
 
ScrollWindow(hWnd, 0, yPos - si.nPos, NULL, NULL);


__in const RECT *lpRect,
__in const RECT *lpClipRect

They are NULL
O.K. I did it. I define a RECT for lpClipRect and used UpdateWindow instead of my function. Now it works, even if the splashing happens sometimes.
If you need more elements inside the scroller you may use the following structure:

div id="wrapper">
<div id="scroller">
<ul>
<li></li>
...
...
</ul>

<ul>
<li></li>
...
...
</ul>
</div>
</div>



This is C++ not XHTML. Can I use XHTML tags inside an EDIT control?
Topic archived. No new replies allowed.