Get the size of the non-client area of ​​the thematic Edit Control

How do you get the border width (non-client) of an Edit theme control in Windows XP and later?

In Windows 7, GetThemeMetricwith TMT_BORDERSIZEas identifier properties returns 0 for the existing edit control, and 1 if no handle. But upon closer inspection, it seems like it should be 2.

If the window styles are enabled for the control WS_VSCROLLor WS_HSCROLL, then the scroll bars are drawn inside this border, and they really are 2 pixels from the outer edge of the control, so I assume there is a way to get the right information.

The reason for the request is that I can set the size of the client area when it WM_NCCALCSIZEoccurs when creating a custom control.

enter image description here

+4
source share
1 answer

How do you get the border width (non-client) of the thematic Edit control in Windows XP and later?

The following steps are for all controls, whether they are thematic or not. It doesn't even need a theme API.

  • Call GetClientRect()to get the size of the client area.
  • Call ClientToScreen()to convert the click directly to the screen coordinates.
  • Call GetWindowRect()to get the rectangle of the control, including the CNC area, in the coordinates of the screen.
  • rect window rect, (, leftBorderWidth = clientRect.left - windowRect.left).

Edit:

, Wine theme_edit.c GetThemeMetric(). GetSystemMetrics() SM_CXEDGE SM_CYEDGE.

(Windows 7 Windows 10) 2.

+4

Source: https://habr.com/ru/post/1691774/


All Articles