0

How do you get the area between the contents displayed in the client area (say notepad) and the scrollbar. There is a slight gap / border in there. How is that determined?

TIA!!

Here's an example: Note part of the small "j" shows but there is a border between that and the scrollbar on the right. How do you know that gap because the client RECT includes the gap?

enter image description here

user3161924
  • 1,849
  • 18
  • 33
  • 1
    Please add necessary screenshot in the question and what kind of work you want to accomplish. Refer: [How to create a Minimal, Reproducible Example](https://stackoverflow.com/help/minimal-reproducible-example) – Strive Sun Aug 07 '20 at 06:02
  • Added picture to show the border/margin area. – user3161924 Aug 07 '20 at 06:49
  • On my notepad, "j" will be placed on the next line instead of being cut off by the scroll bar. This is a very strange phenomenon. – Strive Sun Aug 07 '20 at 07:42
  • 1
    As asked, the question cannot be answered, because [there are two types of scrollbars](https://devblogs.microsoft.com/oldnewthing/20040510-00/?p=39413), and we don't know which one you are using. – IInspectable Aug 07 '20 at 08:55
  • Your picture doesn't make much sense.... Please post another one – Jabberwocky Aug 07 '20 at 09:25
  • This is notepad, so it's the scrollbars in notepad (that gray bar to the right is the vertical scrollbar) . The question is how to get the actually usable area of the client area. Or is the app making up that border? – user3161924 Aug 07 '20 at 15:21

1 Answers1

1

Notepad uses standard EDIT control for its text area. EDIT control implements two messages: EM_GETMARGINS and EM_GETRECT. Values returned by EM_GETMARGINS and EM_GETRECT depend on selected font.

For Courier New at 96 DPI:

height   client rect EM_GETMARGINS EM_GETRECT  right margin
         left right  left right    left right  by EM_GETRECT
10pt     0    489    2    1        3    487    2
20pt     0    489    5    3        6    485    4

For Lucida Console at 96 DPI:

height   client rect EM_GETMARGINS EM_GETRECT  right margin
         left right  left right    left right  by EM_GETRECT
10pt     0    489    0    0        1    488    1
20pt     0    489    0    1        1    487    2

For Consolas at 96 DPI:

height   client rect EM_GETMARGINS EM_GETRECT  right margin
         left right  left right    left right  by EM_GETRECT
10pt     0    489    3    3        5    485    4
20pt     0    489    7    6        8    482    7

For some reason EM_GETMARGINS and EM_GETRECT return slightly different margins. Inspecting them visually it seems that EM_GETRECT produces more correct results.

These are default values. Notepad can modify them but on Windows 10 values are as specified above. Beware that on Windows 10 one white pixel belongs to vertical scroll bar (it could be verified by hovering over it, witch result in scroll bar's thumb highlight and changing cursor from i-beam to arrow).

It looks that you are using Consolas and get default margins.

Daniel Sęk
  • 2,504
  • 1
  • 8
  • 17