View Issue Details

IDProjectCategoryView StatusLast Update
0005262JEDI VCL00 JVCL Componentspublic2011-06-10 16:10
ReporterMoritz BeutelAssigned Toobones 
PrioritynormalSeveritymajorReproducibilityalways
Status resolvedResolutionfixed 
Product VersionDaily / GIT 
Target VersionFixed in Version3.40 
Summary0005262: NONCLIENTMETRICS size changes are not handled correctly
DescriptionA new Vista-specific field was added to the NONCLIENTMETRICS record in
D2010. This means that SizeOf(NONCLIENTMETRICS) now yields a different
value than before - which causes SystemParametersInfo() to fail on
Win2k/XP/2003. The solution is to call the newly added
class function 'NONCLIENTMETRICS.SizeOf' instead of directly using
SizeOf().

NONCLIENTMETRICS is used throughout the JVCL, and most uses are broken
without notice. But in one instance a workaround has been applied - in
JvDockSupportProc.pas, by hard-coding the structure sizes:
// -----
  // Classic XP Era record sizes for TNONCLIENTMETRICSA or
  // TNONCLIENTMETRICSW
  {$ifdef UNICODE}
  JVDOCK_TNONCLIENTMETRICS_SZ = 500; // TNONCLIENTMETRICSW
  {$else}
  JVDOCK_TNONCLIENTMETRICS_SZ = 340; // TNONCLIENTMETRICSA
  {$endif}
// -----

I don't think this is a good idea - it's going to fail again for
Win64. I'd use this solution instead:
// -----
function JvDockGetNoNClientMetrics: TNONCLIENTMETRICS;
begin
{$IFDEF COMPILER14_UP}
  Result.cbSize := TNONCLIENTMETRICS.SizeOf;
{$ELSE}
  Result.cbSize := SizeOf(TNONCLIENTMETRICS);
{$ENDIF}
  Win32Check (SystemParametersInfo(SPI_GETNONCLIENTMETRICS,
    Result.cbSize, @Result, 0));
 end;
// -----

I've created patches (WinMerge, unified mode) which apply these fixes
to the current revision of JVCL.
TagsNo tags attached.

Activities

2010-06-10 03:09

 

JVCL NONCLIENTMETRICS patches.zip (5,140 bytes)

obones

2010-06-10 16:11

administrator   ~0017487

Thanks, this has now been committed in SVN

Issue History

Date Modified Username Field Change
2010-06-10 03:09 Moritz Beutel New Issue
2010-06-10 03:09 Moritz Beutel File Added: JVCL NONCLIENTMETRICS patches.zip
2010-06-10 16:11 obones Note Added: 0017487
2010-06-10 16:11 obones Status new => resolved
2010-06-10 16:11 obones Fixed in Version => Daily / SVN
2010-06-10 16:11 obones Resolution open => fixed
2010-06-10 16:11 obones Assigned To => obones
2011-06-10 16:10 obones Fixed in Version Daily / SVN => 3.40