0

Let's say you have a resizable window with child scrollbar controls, and the scrollbars come and go depending on whether the window contents are large enough to require scrolling.

When both scrollbars are present, a small rectangle is effectively created in the bottom right corner of the window, at their intersection. Is there a clean strategy for clipping that rectangle when drawing on the window, so that you don't paint on it?

I guess my current approach is to obtain the rectangles for each scrollbar, and if those rectangles are not null, then use the rectangles' locations to determine the rectangle that we want to clip. And then call ExcludeClipRect for that rectangle. I guess a similar approach could be used, except with GetSystemMetrics(SM_CXVSCROLL) and GetSystemMetrics(SM_CYVSCROLL) to get the rectangle dimensions.

But is there a more accepted way of doing this, perhaps using some helpful clipping API functions? Thank you for any input.

  • `GetClientRect` gets the drawable area of the window excluding scrollbars. https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getclientrect – Richard Critten Feb 23 '21 at 00:57
  • Is the scroll bar control created by specifying the `WS_VSCROLL` style, or by specifying the `SCROLLBAR` class? – Strive Sun Feb 23 '21 at 02:03
  • They're scrollbars created with the `SCROLLBAR` class. –  Feb 23 '21 at 02:28
  • Maybe you can limit the dimensions of scroll controls. Like [this](https://i.stack.imgur.com/jT4os.png). – Strive Sun Feb 23 '21 at 02:49
  • 1
    What problem with your proposed solution are you trying to solve? Deriving dependent information from the actual data sounds like the most robust solution. – IInspectable Feb 23 '21 at 08:12

0 Answers0