Skip to content
Permalink
Browse files

Initialize NONCLIENTMETRICSW structure to be compatible with Windows …

…Vista and later

Now that we no longer support Windows XP, we can safely assume that NONCLIENTMETRICSW structure always has |iPaddedBorderWidth| field and take it into consideration when calculating |NONCLIENTMETRICSW::cbSize| member.

See http://blogs.msdn.com/b/oldnewthing/archive/2003/12/12/56061.aspx about why simply specifying |sizeof(NONCLIENTMETRICSW)| to |NONCLIENTMETRICSW::cbSize| is a bug-prone.

This is just an internal clean-up.  No user-visible behavior change is intended.

BUG=none
TEST=none

git-svn-id: https://mozc.googlecode.com/svn/trunk@539 a6090854-d499-a067-5803-1114d4e51264
  • Loading branch information...
yukawa committed Feb 8, 2015
1 parent c8fdbc9 commit d2e723933c34506dc6e524eab63e07e2ad9931a6
Showing with 7 additions and 13 deletions.
  1. +6 −12 src/gui/base/locale_util.cc
  2. +1 −1 src/mozc_version_template.txt
@@ -161,18 +161,12 @@ TranslationDataImpl::TranslationDataImpl()
// Get the font from MessageFont
NONCLIENTMETRICSW ncm = { 0 };

// Note that SystemParametersInfoW fails on Windows XP when |ncm.cbSize| is
// greater than 500 (bytes), which means that this function is no longer
// compatible with XP if WINVER >= 0x0600 because a new field named
// |iPaddedBorderWidth| was added at the last of NONCLIENTMETRICS structure
// in Windows Vista. It would be better to initialize |ncm.cbSize| to be
// compatible with Windows XP unless you rely on |iPaddedBorderWidth|.
// For background information, you can read:
// http://d.hatena.ne.jp/NyaRuRu/20080303/p1
// http://blogs.msdn.com/b/oldnewthing/archive/2003/12/12/56061.aspx
const size_t kSizeOfNonClientMetricsWForXpOrPrior =
CCSIZEOF_STRUCT(NONCLIENTMETRICSW, lfMessageFont);
ncm.cbSize = kSizeOfNonClientMetricsWForXpOrPrior;
// We don't use |sizeof(NONCLIENTMETRICSW)| because it is fragile when the
// code is copied-and-pasted without caring about WINVER.
// http://blogs.msdn.com/b/oldnewthing/archive/2003/12/12/56061.aspx
const size_t kSizeOfNonClientMetricsWForVistaOrLater =
CCSIZEOF_STRUCT(NONCLIENTMETRICSW, iPaddedBorderWidth);
ncm.cbSize = kSizeOfNonClientMetricsWForVistaOrLater;
if (::SystemParametersInfoW(SPI_GETNONCLIENTMETRICS, 0, &ncm, 0)) {
// Windows font scale is 0..100 while Qt's scale is 0..99.
// If lfWeight is 0 (default weight), we don't set the Qt's font weight.
@@ -1,6 +1,6 @@
MAJOR=2
MINOR=16
BUILD=2055
BUILD=2056
REVISION=102
# NACL_DICTIONARY_VERSION is the target version of the system dictionary to be
# downloaded by NaCl Mozc.

0 comments on commit d2e7239

Please sign in to comment.
You can’t perform that action at this time.