Problem with System Metrics SM_CXSIZEFRAME + SM_CXPADDEDBORDER in Windows 10 Preview (Build 10041) RRS feed

  • Question

  • Maybe this forum is the wrong place to ask something about Windows 10 Preview, but I did not find a dedicated place to report programming problems as opposed to user problems:

    I program/maintain a 32-bit desktop (WIN32 API) application and try it now on Windows 10 Preview build 10041. I calculate the size of a window border with the help of the GetSystemMetrics function, using the constants SM_CXSIZEFRAME and SM_CXPADDEDBORDER.

    Originally, I only used SM_CXSIZEFRAME. This returned 4 pixels instead of the expected 8 pixels that I got on all previous windows versions up to Windows 8.1. Then I learned that already since Windows Vista one is expected to add the value of SM_CXPADDEDBORDER to get the full border size. (SM_CXSIZEFRAME alone only continued to work on Vista and beyond thanks to a little compatibility hack by Microsoft, with SM_CXSIZEFRAME still returning the full border size and SM_CXPADDEDBORDER returning yet 0, at least for 32-bit programs like mine.)

    Assuming that Microsoft finally switched off that compatibility measure on Windows 10 I query and add SM_CXPADDEDBORDER now as well. Unfortunately this does not solve my problem, as that system metric returns 0.

    Just to be on the sure side, I declared my program to support Windows 10 by using an embedded manifest and using the corresponding <compatibility> / <supportedOS> line with the Windows 10 GUID - this did not help either.

    As querying and adding those two system metric values is rather trivial (no need to include code in this question, I think), I don't have the slightest idea what I could do wrong here, this looks like Preview bug affecting 32-bit programs to me...

    Saturday, April 18, 2015 1:57 PM


All replies

  • Try AdjustWindowRect[Ex]

    Igor Tandetnik
    Saturday, April 18, 2015 2:22 PM
  • I regret to inform you, that you have to live with this error for ever. Microsoft won't fix it... we reported an error of the Windows Error Reporting system (exists since Windows 8) and provided a reproduction (an application with one printed page of code, so very small and easy). It has never been fixed. 3 developers at Microsoft are involved and they confirmed, that it's a bug ... but... no chance. It's a strange company... I don't know what they mean with "we listen to our customers".

    PS: ja, nöd grad hilfriich mini Kommentär, aber die Type triibed eim eifach in Wahnsinn!! ... schinbar nöd nur öschtlich vo Bade, sondern au weschtlich


    Sunday, April 19, 2015 2:46 PM
  • Thanks, AdjustWindowRect does not suffer from the same problem, i.e. calculates the correct border size given the right window style, and I can use it to circumvent the problem with SM_CXPADDEDBORDER coming back as 0.

    Monday, April 20, 2015 9:42 AM
  • Thanks to Rudolf Meier for this interesting information about the history of this. Does not help, as you write, but good to know - it drove me to try AdjustWindowRect, which does work, instead of programming some ugly hack when finding that I run under Windows 10.
    • Edited by rbrunner7 Monday, April 20, 2015 12:11 PM
    Monday, April 20, 2015 9:45 AM
  • Another solution is to mark your app (using the linker) with Windows subsystem 6.0 instead of 5.01.   SM_CXPADDEDBORDER returns 4 when you do that. 

    Although you do lose XP support when you do this.

    • Edited by Ted_ Wednesday, May 6, 2015 1:24 AM
    Wednesday, May 6, 2015 1:21 AM
  • Looks like this is fixed in Windows 10 preview build 10122. No code changes required to your app.
    Thursday, May 21, 2015 6:14 PM