1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83
| unit GUITweak;
interface
uses Windows, SysUtils;
type
TMetricData = (mdScrollWidth,
mdScrollHeight,
mdCaptionHeight, //Hauteur de la barre de titre -> Boutons système
mdSmallCaptionHeight, //Hauteur de la petite barre de titre -> Boutons système
mdMenuHeight
);
function RestoreMetrics: Boolean;
function SetNonClientMetrics(aSize :integer; aMetricData :TMetricData) :boolean;
implementation
var
MetricModified :boolean = FALSE;
OldMetrics :NONCLIENTMETRICS;
CurrentMetrics :NONCLIENTMETRICS;
procedure SaveMetrics;
begin
OldMetrics.cbSize := SizeOf(OldMetrics);
SystemParametersInfo(SPI_GETNONCLIENTMETRICS, SizeOf(OldMetrics), @OldMetrics, SPIF_SENDCHANGE);
CurrentMetrics := OldMetrics;
end;
function RestoreMetrics: Boolean;
begin
if MetricModified then
begin
Result := SystemParametersInfo(SPI_SETNONCLIENTMETRICS, SizeOf(OldMetrics), @OldMetrics, SPIF_SENDCHANGE);
if Result then
begin
MetricModified := FALSE;
CurrentMetrics := OldMetrics;
end;
end;
end;
function SetNonClientMetrics(aSize :integer; aMetricData :TMetricData) :boolean;
function Check(aOld :integer; var aCurrent :integer) :boolean;
begin
Result := ((aSize = 0) and (aCurrent <> aOld)) or
((aSize <> 0) and (aSize <> aCurrent));
if Result then
if aSize = 0
then aCurrent := aOld
else aCurrent := aSize;
end;
begin
case aMetricData of
mdScrollWidth : Result := Check(OldMetrics.iScrollWidth, CurrentMetrics.iScrollWidth);
mdScrollHeight : Result := Check(OldMetrics.iScrollHeight, CurrentMetrics.iScrollHeight);
mdCaptionHeight : Result := Check(OldMetrics.iCaptionHeight, CurrentMetrics.iCaptionHeight);
mdSmallCaptionHeight : Result := Check(OldMetrics.iSmCaptionHeight, CurrentMetrics.iSmCaptionHeight);
mdMenuHeight : Result := Check(OldMetrics.iMenuHeight, CurrentMetrics.iMenuHeight);
else Result := FALSE;
end;
if Result then
Result := SystemParametersInfo(SPI_SETNONCLIENTMETRICS, SizeOf(CurrentMetrics), @CurrentMetrics, SPIF_SENDCHANGE);
MetricModified := MetricModified or Result;
end;
initialization
SaveMetrics;
finalization
RestoreMetrics;
end. |
Partager