window border width and height in Win32 - how do I get it?

前端 未结 6 918
慢半拍i
慢半拍i 2020-12-08 10:10
      ::GetSystemMetrics (SM_CYBORDER)

...comes back with 1 and I know the title bar is taller than ONE pixel :/

I also tried:

     RECT r;
         


        
6条回答
  •  南方客
    南方客 (楼主)
    2020-12-08 10:31

    int border_thickness = GetSystemMetrics(SM_CXSIZEFRAME);
    

    In fact, the above result might be equal to:

    GetClientRect(hWnd, &rcClient); 
    GetWindowRect(hWnd, &rcWind); 
    int border_thickness = ((rcWind.right - rcWind.left) - rcClient.right) / 2; 
    

    but GetSystemMetrics(SM_CXSIZEFRAME) is easier to be used.

提交回复
热议问题