Article View: borland.public.cppbuilder.migration
Article #145Re: Call to SystemParametersInfo() no longer works under Borland C++ Builder 7
From: Remy Lebeau (TeamB)
Date: Tue, 05 Aug 2008 20:45
Date: Tue, 05 Aug 2008 20:45
53 lines
3241 bytes
3241 bytes
"James O'Brien" <obrien@niscnet.com> wrote in message
news:4898b6ce$1@newsgroups.borland.com...
> I have code which performs custom painting to a window's title
> bar(non-client area). I recently migrated from "C++ Build v6" to
> "C++ Builder 2007" and calls to SystemParametersInfo() no
> longer work.
That is because the NONCLIENTMETRICS structure changed between those two
versions. BCB2007 has a newer Platform SDK, where the structure has an
additional iPaddedBorderWidth that did not exist yet in the SDK that BCB6
has. You are setting the cbSize member to the newer structure size, which
is not valid on the OS you are calling SystemParametersInfo() on. You have
to take the OS version into account when using API structures that have a
cbSize member, such as NONCLIENTMETRICS. This is clearly stated in the
documentation for NONCLIENTMETRICS:
http://msdn.microsoft.com/en-us/library/ms724506(VS.85).aspx
If the iPaddedBorderWidth member of the NONCLIENTMETRICS structure is
present, this structure is 4 bytes larger than for an application that is
compiled with _WIN32_WINNT less than or equal to 0x0502. For more
information about conditional compilation, see Using the Windows Headers
(http://msdn.microsoft.com/en-us/library/aa383745(VS.85).aspx).
Windows Server 2003 and Windows XP/2000: If an application that is
compiled for Windows Server 2008 or Windows Vista must also run on Windows
Server 2003 or Windows XP/2000, use the GetVersionEx function to check the
operating system version at run time and, if the application is running on
Windows Server 2003 or Windows XP/2000, subtract the size of the
iPaddedBorderWidth member from the cbSize member of the NONCLIENTMETRICS
structure before calling the SystemParametersInfo function.
In other words, you need to update your code to do something like the
following:
NONCLIENTMETRICS NCM = {0};
NCM.cbSize = sizeof(NONCLIENTMETRICS);
if( Win32MajorVersion < 6 )
{
NCM.cbSize -= 4;
// alternatively:
// NCM.cbSize = offsetof(NONCLIENTMETRICS, iPaddedBorderWidth);
}
SystemParametersInfo(SPI_GETNONCLIENTMETRICS, NCM.cbSize, (PVOID)&NCM,
0);
Gambit
Technical Details
Message-ID:
<4898bc71$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news2.google.com!news4.google.com!proxad.net!feeder1-2.proxad.net!194.25.134.126.MISMATCH!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<4898b6ce$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 110f51,9e6e6ebe95bfafce X-Google-Attributes: gid110f51,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit From: "Remy Lebeau \(TeamB\)" <no.spam@no.spam.com> Newsgroups: borland.public.cppbuilder.migration References: <4898b6ce$1@newsgroups.borland.com> Subject: Re: Call to SystemParametersInfo() no longer works under Borland C++ Builder 7 Date: Tue, 5 Aug 2008 13:45:56 -0700 Lines: 56 Organization: Lebeau Software X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.3138 X-RFC2646: Format=Flowed; Original X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3198 NNTP-Posting-Host: 207.178.157.90 Message-ID: <4898bc71$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1217969265 207.178.157.90 (5 Aug 2008 13:47:45 -0700) Path: arc1-ca.pugleaf.net!g2news2.google.com!news4.google.com!proxad.net!feeder1-2.proxad.net!194.25.134.126.MISMATCH!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail