Button size algorithm
-
Does anyone know the algorithm used by ::MessageBox() to work out how big to make the buttons in the dialog box? It seems to depend on the font size chosen in Display Properties -> Advanced -> Item = Message Box. Information about the font is available in ncm.lfMessageFont after doing: NONCLIENTMETRICS ncm; memset(&ncm, 0, sizeof(ncm)); ncm.cbSize = sizeof(ncm); ::SystemParametersInfo(SPI_GETNONCLIENTMETRICS, 0, &ncm, 0); but how does ::MessageBox() get from there to the default button width and height? I've had a look at all the Windows routines that give system information, but I can't find the answer. Cheers, Chris.
-
Does anyone know the algorithm used by ::MessageBox() to work out how big to make the buttons in the dialog box? It seems to depend on the font size chosen in Display Properties -> Advanced -> Item = Message Box. Information about the font is available in ncm.lfMessageFont after doing: NONCLIENTMETRICS ncm; memset(&ncm, 0, sizeof(ncm)); ncm.cbSize = sizeof(ncm); ::SystemParametersInfo(SPI_GETNONCLIENTMETRICS, 0, &ncm, 0); but how does ::MessageBox() get from there to the default button width and height? I've had a look at all the Windows routines that give system information, but I can't find the answer. Cheers, Chris.
It is base on DialogBaseUnits. The buttons are sized in DialogBaseUnits, and the size in pixels is calculated using the MapDialogRect() function that converts from DialogBaseUnits to pixels depending on the font used.
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03 "Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04 Within you lies the power for good - Use it!