CScrollView does not repaint the whole area

Zoltán Hegedüs 101 Reputation points
2021-04-08T13:00:04.297+00:00

My IDE shows the pair of () {} [] at the caret: for example, if the character at the caret is (, shows ) with different background. For example, if I press Caret Down, when the caret is on the last visible line, scrolls 1 line with ScrollToPosition. This calls OnDraw, what repaint the whole visible area, but CScrollView uses only the last line form this: on the other part of the window, scrolls the original content. So, the caret moved, but the highlighting of the pair of the bracket remains: will be a lot of highlighted characters.

C++
C++
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
3,537 questions
{count} votes

Accepted answer
  1. Viorel 112.5K Reputation points
    2021-04-08T14:57:37.567+00:00

    In my opinion, when you want to modify something in your view, you should call InvalidateRect or InvalidateRgn for all of changed areas, store the new data, and let the OnPaint or OnDraw handlers to draw the new image using the current data. This will also work when you, for example, minimise and restore the window, which requires repainting too.

    You do not have to draw new characters explicitly. Try calling InvalidateRect two times: for un-highlighted and highlighted characters. Perform the drawing inside the OnDraw only using the supplied pDC.

    0 comments No comments

0 additional answers

Sort by: Most helpful