2008-02-03 12:05:55 +00:00
|
|
|
{*********************************************************}
|
|
|
|
{* VPMISC.PAS 1.03 *}
|
|
|
|
{*********************************************************}
|
|
|
|
|
|
|
|
{* ***** BEGIN LICENSE BLOCK ***** *}
|
|
|
|
{* Version: MPL 1.1 *}
|
|
|
|
{* *}
|
|
|
|
{* The contents of this file are subject to the Mozilla Public License *}
|
|
|
|
{* Version 1.1 (the "License"); you may not use this file except in *}
|
|
|
|
{* compliance with the License. You may obtain a copy of the License at *}
|
|
|
|
{* http://www.mozilla.org/MPL/ *}
|
|
|
|
{* *}
|
|
|
|
{* Software distributed under the License is distributed on an "AS IS" basis, *}
|
|
|
|
{* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License *}
|
|
|
|
{* for the specific language governing rights and limitations under the *}
|
|
|
|
{* License. *}
|
|
|
|
{* *}
|
|
|
|
{* The Original Code is TurboPower Visual PlanIt *}
|
|
|
|
{* *}
|
|
|
|
{* The Initial Developer of the Original Code is TurboPower Software *}
|
|
|
|
{* *}
|
|
|
|
{* Portions created by TurboPower Software Inc. are Copyright (C) 2002 *}
|
|
|
|
{* TurboPower Software Inc. All Rights Reserved. *}
|
|
|
|
{* *}
|
|
|
|
{* Contributor(s): *}
|
|
|
|
{* *}
|
|
|
|
{* ***** END LICENSE BLOCK ***** *}
|
|
|
|
|
|
|
|
unit VpMisc;
|
|
|
|
{-Miscellaneous functions and procedures}
|
|
|
|
|
|
|
|
interface
|
|
|
|
|
|
|
|
{$I vp.inc}
|
|
|
|
|
|
|
|
uses
|
|
|
|
{$IFDEF LCL}
|
2016-06-22 07:59:17 +00:00
|
|
|
LCLProc, LCLType, LCLIntf,
|
2008-02-03 12:05:55 +00:00
|
|
|
{$ELSE}
|
2016-06-22 07:59:17 +00:00
|
|
|
Windows, Consts, Messages,
|
2008-02-03 12:05:55 +00:00
|
|
|
{$ENDIF}
|
2016-09-10 17:26:42 +00:00
|
|
|
Buttons, Classes, Controls, StdCtrls, ExtCtrls, Forms, Graphics, Menus,
|
2008-02-03 12:05:55 +00:00
|
|
|
SysUtils, VpBase, VpData, VpConst;
|
|
|
|
|
|
|
|
type
|
|
|
|
TDayList = array[1..12] of Word;
|
|
|
|
|
|
|
|
|
2016-07-08 11:05:54 +00:00
|
|
|
TVpDayType = (dtSunday, dtMonday, dtTuesday, dtWednesday, dtThursday, dtFriday, dtSaturday);
|
2008-02-03 12:05:55 +00:00
|
|
|
|
2016-07-08 11:05:54 +00:00
|
|
|
TVpDateFormat = (dfShort, dfLong);
|
2008-02-03 12:05:55 +00:00
|
|
|
|
|
|
|
TVpDayNameWidth = Integer;
|
|
|
|
|
|
|
|
const
|
|
|
|
MonthDays: array [Boolean] of TDayList =
|
|
|
|
((31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31),
|
|
|
|
(31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31));
|
|
|
|
|
2016-06-20 10:21:06 +00:00
|
|
|
GranularityMinutes: Array[TVpGranularity] of Integer = (5, 6, 10, 15, 20, 30, 60);
|
|
|
|
|
2008-02-03 12:05:55 +00:00
|
|
|
function DaysInMonth(Year, Month : Integer) : Integer;
|
|
|
|
{-return the number of days in the specified month of a given year}
|
|
|
|
function DefaultEpoch : Integer;
|
|
|
|
{-return the current century}
|
2016-07-12 18:00:32 +00:00
|
|
|
//function GetLeftButton : Byte;
|
2008-02-03 12:05:55 +00:00
|
|
|
procedure GetRGB(Clr : TColor; var IR, IG, IB : Byte);
|
|
|
|
function IsLeapYear(Year : Integer) : Boolean;
|
|
|
|
function GetStartOfWeek(Date: TDateTime; StartOn: TVpDayType): TDateTime;
|
|
|
|
|
|
|
|
procedure StripString(var Str: string);
|
|
|
|
{ strips non-alphanumeric characters from the beginning and end of the string}
|
|
|
|
function AssembleName(Contact: TVpContact): string;
|
|
|
|
{ returns an assembled name string }
|
|
|
|
procedure ParseName(Contact: TVpContact; const Value: string);
|
|
|
|
{ parses the name into it's elements and updates the contact }
|
|
|
|
procedure ParseCSZ(Str: string; var City, State, Zip: string);
|
2016-07-12 09:26:14 +00:00
|
|
|
{ parses the string and returns the city, state and zip parameters }
|
|
|
|
|
|
|
|
{$IFDEF DELPHI}
|
2008-02-03 12:05:55 +00:00
|
|
|
function LoadBaseBitmap(lpBitmapName : PAnsiChar) : HBITMAP;
|
|
|
|
{-load and return the handle to bitmap resource}
|
|
|
|
function LoadBaseCursor(lpCursorName : PAnsiChar) : HCURSOR;
|
2016-07-12 09:26:14 +00:00
|
|
|
{-load and return the handle to cursor resource}
|
|
|
|
{$ENDIF}
|
|
|
|
|
2008-02-03 12:05:55 +00:00
|
|
|
function HeightOf(const R : TRect) : Integer;
|
|
|
|
{- return the height of the TRect}
|
|
|
|
function WidthOf(const R : TRect) : Integer;
|
|
|
|
{- return the width of the TRect}
|
2016-07-08 11:05:54 +00:00
|
|
|
function RightOf(AControl: TControl): Integer;
|
|
|
|
{- returns the right edge of a control }
|
2016-07-13 22:58:32 +00:00
|
|
|
function BottomOf(AControl: TControl): Integer;
|
|
|
|
{- returns the bottom edge of a control }
|
2016-07-12 09:26:14 +00:00
|
|
|
|
2008-02-03 12:05:55 +00:00
|
|
|
function GetDisplayString(Canvas : TCanvas; const S : string;
|
|
|
|
MinChars, MaxWidth : Integer) : string;
|
|
|
|
{-given a string, a minimum number of chars to display, and a max width, }
|
|
|
|
{ find the string that can be displayed in that width - add ellipsis to }
|
|
|
|
{ the end if necessary and possible }
|
|
|
|
procedure DrawBevelRect(const Canvas: TCanvas; R: TRect;
|
|
|
|
Shadow, Highlight: TColor);
|
|
|
|
{-draws a bevel in the specified TRect, using the specified colors }
|
|
|
|
function PointInRect(Point: TPoint; Rect: TRect): Boolean;
|
|
|
|
{-determines if the specified point resides inside the specified TRect }
|
|
|
|
|
2016-06-24 20:00:32 +00:00
|
|
|
function GetAlarmAdvanceTime(Advance: Integer; AdvanceType: TVpAlarmAdvType): TDateTime;
|
2008-02-03 12:05:55 +00:00
|
|
|
|
2016-06-24 20:00:32 +00:00
|
|
|
{$IFDEF DELPHI}{$IFNDEF Delphi6}
|
|
|
|
function MonthOfTheYear(TheDate: TDateTime): Word;
|
|
|
|
procedure IncAMonth(var Year, Month, Day: Word; NumMonths: Integer);
|
|
|
|
function IncMonth(const TheDate: TDateTime; NumberOfMonths: Integer): TDateTime;
|
|
|
|
function IncYear(TheDate: TDateTime; NumYears: Integer): TDateTime;
|
2016-07-04 19:00:42 +00:00
|
|
|
function TimeOf(ADateTime: TDateTime): TDateTime;
|
|
|
|
function DateOf(ADateTime: TDateTime): TDateTime;
|
2016-06-24 20:00:32 +00:00
|
|
|
{$ENDIF}{$ENDIF}
|
2008-02-03 12:05:55 +00:00
|
|
|
|
|
|
|
function GetJulianDate(Date: TDateTime): Word;
|
2016-06-24 20:00:32 +00:00
|
|
|
function GetWeekOfYear(ADate: TDateTime): byte;
|
2016-07-04 21:35:15 +00:00
|
|
|
function IsWeekEnd(ADate: TDateTime): Boolean;
|
2016-06-24 20:00:32 +00:00
|
|
|
function SameDate(dt1, dt2: TDateTime): Boolean;
|
2016-07-04 19:21:55 +00:00
|
|
|
function DateInRange(ADate, StartDate, EndDate: TDateTime; IncludeLimits: Boolean): Boolean;
|
|
|
|
function TimeInRange(ATime, StartTime, EndTime: TDateTime; IncludeLimits: Boolean): Boolean;
|
2008-02-03 12:05:55 +00:00
|
|
|
|
2016-08-08 18:29:24 +00:00
|
|
|
function GetTimeFormat: TVpTimeFormat;
|
2016-09-12 22:25:34 +00:00
|
|
|
function GetTimeFormatStr(ATimeFormat: TVpTimeFormat): String;
|
2016-07-05 22:21:02 +00:00
|
|
|
function GranularityToStr(Gran: TVpGranularity): string;
|
|
|
|
function HourToAMPM(Hour: TVpHours): string;
|
|
|
|
function HourToStr(Hour: TVpHours; Mil: Boolean): string;
|
|
|
|
|
2016-06-20 11:00:59 +00:00
|
|
|
function HourToLine(const Value: TVpHours; const Granularity: TVpGranularity): Integer;
|
|
|
|
function GetStartLine(StartTime: TDateTime; Granularity: TVpGranularity): Integer;
|
2016-07-06 06:10:58 +00:00
|
|
|
function GetEndLine(EndTime: TDateTime; Granularity: TVpGranularity): Integer;
|
2008-02-03 12:05:55 +00:00
|
|
|
function LineToStartTime(Line: Integer; Granularity: TVpGranularity): TDateTime;
|
|
|
|
function GetLineDuration(Granularity: TVpGranularity): Double;
|
|
|
|
|
2016-07-21 11:15:26 +00:00
|
|
|
function AutoHeight(ARadioGroup: TRadioGroup): Integer;
|
2016-07-14 12:20:59 +00:00
|
|
|
function GetButtonWidth(AButton: TButton): Integer;
|
2016-06-20 11:00:59 +00:00
|
|
|
function GetLabelWidth(ALabel: TLabel): Integer;
|
2016-07-02 22:46:05 +00:00
|
|
|
function GetRealFontHeight(AFont: TFont): Integer;
|
2016-06-10 16:12:14 +00:00
|
|
|
|
2016-06-27 22:43:15 +00:00
|
|
|
function DecodeLineEndings(const AText: String): String;
|
|
|
|
function EncodeLineEndings(const AText: String): String;
|
2016-09-11 17:53:51 +00:00
|
|
|
function StripLastLineEnding(const AText: String): String;
|
2016-06-27 22:43:15 +00:00
|
|
|
|
2016-09-10 17:26:42 +00:00
|
|
|
procedure AddResourceGroupMenu(AMenu: TMenuItem; AResource: TVpResource;
|
|
|
|
AEventHandler: TNotifyEvent);
|
2016-09-10 20:08:06 +00:00
|
|
|
function OverlayPatternToBrushStyle(APattern: TVpOverlayPattern): TBrushStyle;
|
2016-09-10 17:26:42 +00:00
|
|
|
|
2016-07-14 09:40:54 +00:00
|
|
|
{$IFDEF LCL}
|
|
|
|
procedure HighDPI(FromDPI: integer);
|
|
|
|
procedure ScaleDPI(Control: TControl; FromDPI: integer);
|
|
|
|
|
|
|
|
const
|
|
|
|
DesignTimeDPI = 96;
|
|
|
|
{$ENDIF}
|
|
|
|
|
2016-07-12 09:26:14 +00:00
|
|
|
procedure Unused(const A1); overload;
|
|
|
|
procedure Unused(const A1, A2); overload;
|
|
|
|
procedure Unused(const A1, A2, A3); overload;
|
2016-06-24 10:33:55 +00:00
|
|
|
|
2008-02-03 12:05:55 +00:00
|
|
|
implementation
|
|
|
|
|
|
|
|
uses
|
2016-07-04 19:00:42 +00:00
|
|
|
{$IFDEF LCL}
|
|
|
|
DateUtils,
|
|
|
|
{$ENDIF}
|
2016-09-10 17:26:42 +00:00
|
|
|
VpException, VpSR, VpBaseDS;
|
2008-02-03 12:05:55 +00:00
|
|
|
|
|
|
|
procedure StripString(var Str: string);
|
|
|
|
begin
|
2016-07-04 19:00:42 +00:00
|
|
|
if Length(Str) < 1 then
|
2008-02-03 12:05:55 +00:00
|
|
|
Exit;
|
2016-06-23 11:53:21 +00:00
|
|
|
while (Length(Str) > 0) and (not (Str[1] in ['A'..'Z', 'a'..'z', '0'..'9'])) do
|
2008-02-03 12:05:55 +00:00
|
|
|
delete(Str, 1, 1);
|
2016-06-23 11:53:21 +00:00
|
|
|
while (Length(Str) > 0) and (not (Str[Length(Str)] in ['A'..'Z', 'a'..'z', '0'..'9'])) do
|
2008-02-03 12:05:55 +00:00
|
|
|
delete(Str, Length(Str), 1);
|
|
|
|
end;
|
|
|
|
{=====}
|
|
|
|
|
|
|
|
function AssembleName(Contact: TVpContact): string;
|
|
|
|
begin
|
|
|
|
result := Contact.LastName;
|
|
|
|
if Assigned (Contact.Owner) then begin
|
|
|
|
if Contact.Owner.ContactSort = csFirstLast then begin
|
|
|
|
if Contact.FirstName <> '' then
|
|
|
|
result := Contact.FirstName + ' ' + Result;
|
|
|
|
end else begin
|
|
|
|
if Contact.FirstName <> '' then
|
|
|
|
result := result + ', ' + Contact.FirstName;
|
|
|
|
end;
|
|
|
|
end else begin
|
|
|
|
if Contact.FirstName <> '' then
|
|
|
|
result := result + ', ' + Contact.FirstName;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
{=====}
|
|
|
|
|
|
|
|
procedure ParseName(Contact: TVpContact; const Value: string);
|
|
|
|
var
|
|
|
|
name, ln, fn: string;
|
|
|
|
begin
|
|
|
|
name := Value;
|
|
|
|
|
|
|
|
{ strip spaces from the beginning and end of the name string }
|
|
|
|
StripString(name);
|
|
|
|
|
|
|
|
{ parse string }
|
|
|
|
if pos(',', name) > 0 then begin
|
|
|
|
{ lastname, firstname }
|
|
|
|
ln := copy(name, 1, pos(',', name) -1);
|
|
|
|
fn := copy(name, pos(',', name), length(name));
|
|
|
|
end else begin
|
|
|
|
{ firstname lastname }
|
|
|
|
ln := copy(name, LastDelimiter(' ', name), length(name));
|
|
|
|
fn := copy(name, 1, LastDelimiter(' ', name) - 1);
|
|
|
|
end;
|
|
|
|
|
|
|
|
{ strip fn and ln strings }
|
|
|
|
StripString(fn);
|
|
|
|
StripString(ln);
|
|
|
|
|
|
|
|
{ assign the strings to the proper contact fields }
|
|
|
|
Contact.LastName := ln;
|
|
|
|
Contact.FirstName := fn;
|
|
|
|
end;
|
|
|
|
{=====}
|
|
|
|
|
|
|
|
procedure ParseCSZ(Str: string; var City, State, Zip: string);
|
|
|
|
var
|
|
|
|
num: integer;
|
|
|
|
begin
|
|
|
|
StripString(Str);
|
|
|
|
|
|
|
|
if Pos(',', Str) > 0 then begin
|
|
|
|
City := copy (Str, 1, pos(',', str) - 1);
|
|
|
|
delete(str, 1, pos(',', str));
|
|
|
|
end;
|
|
|
|
|
|
|
|
num := LastDelimiter(' ', Str);
|
|
|
|
|
|
|
|
if (num > 0)
|
|
|
|
and (num < Length(Str))
|
|
|
|
and (Str[num + 1] in ['0'..'9']) then begin
|
|
|
|
Zip := copy(Str, num, length(Str));
|
|
|
|
Delete(Str, num, length(str));
|
|
|
|
end;
|
|
|
|
|
|
|
|
State := Str;
|
|
|
|
|
|
|
|
StripString(City);
|
|
|
|
StripString(State);
|
|
|
|
StripString(Zip);
|
|
|
|
end;
|
|
|
|
{=====}
|
|
|
|
|
2016-07-12 09:26:14 +00:00
|
|
|
{$IFDEF DELPHI}
|
2008-02-03 12:05:55 +00:00
|
|
|
function LoadBaseBitmap(lpBitmapName : PAnsiChar) : HBITMAP;
|
|
|
|
begin
|
2012-09-24 19:08:29 +00:00
|
|
|
{$IFDEF FPC}
|
|
|
|
//wird direkt geladen
|
|
|
|
//fImageList.AddLazarusResource('TABSET_SCROLLER');//, clFuchsia);
|
|
|
|
{$ENDIF}
|
2009-12-24 22:41:52 +00:00
|
|
|
// Result := LoadBitmap(FindClassHInstance(TVpCustomControl), lpBitmapName);
|
2008-02-03 12:05:55 +00:00
|
|
|
end;
|
|
|
|
{=====}
|
|
|
|
|
|
|
|
function LoadBaseCursor(lpCursorName : PAnsiChar) : HCURSOR;
|
|
|
|
begin
|
|
|
|
//TODO: Result := LoadCursor(FindClassHInstance(TVpCustomControl), lpCursorName);
|
|
|
|
end;
|
2016-07-12 09:26:14 +00:00
|
|
|
{$ENDIF}
|
2008-02-03 12:05:55 +00:00
|
|
|
|
|
|
|
function WidthOf(const R : TRect) : Integer;
|
|
|
|
begin
|
|
|
|
Result := R.Right - R.Left;
|
|
|
|
end;
|
|
|
|
{=====}
|
|
|
|
|
|
|
|
function HeightOf(const R : TRect) : Integer;
|
|
|
|
begin
|
|
|
|
Result := R.Bottom - R.Top;
|
|
|
|
end;
|
|
|
|
{=====}
|
|
|
|
|
|
|
|
function GetDisplayString(Canvas : TCanvas; const S : string;
|
|
|
|
MinChars, MaxWidth : Integer) : string;
|
|
|
|
var
|
|
|
|
iDots, EllipsisWidth, Extent, Len, Width : Integer;
|
|
|
|
ShowEllipsis : Boolean;
|
|
|
|
begin
|
|
|
|
{be sure that the Canvas Font is set before entering this routine}
|
|
|
|
EllipsisWidth := Canvas.TextWidth('...');
|
|
|
|
Len := Length(S);
|
|
|
|
Result := S;
|
|
|
|
Extent := Canvas.TextWidth(Result);
|
|
|
|
ShowEllipsis := False;
|
|
|
|
Width := MaxWidth;
|
|
|
|
while (Extent > Width) do begin
|
|
|
|
ShowEllipsis := True;
|
|
|
|
Width := MaxWidth - EllipsisWidth;
|
|
|
|
if Len > MinChars then begin
|
|
|
|
Delete(Result, Len, 1);
|
|
|
|
dec(Len);
|
|
|
|
end else
|
|
|
|
break;
|
|
|
|
Extent := Canvas.TextWidth(Result);
|
|
|
|
end;
|
|
|
|
if ShowEllipsis then begin
|
|
|
|
Result := Result + '...';
|
|
|
|
inc(Len, 3);
|
|
|
|
Extent := Canvas.TextWidth(Result);
|
|
|
|
iDots := 3;
|
|
|
|
while (iDots > 0) and (Extent > MaxWidth) do begin
|
|
|
|
Delete(Result, Len, 1);
|
|
|
|
Dec(Len);
|
|
|
|
Extent := Canvas.TextWidth(Result);
|
|
|
|
Dec(iDots);
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
{=====}
|
|
|
|
|
|
|
|
procedure DrawBevelRect(const Canvas: TCanvas; R: TRect;
|
|
|
|
Shadow, Highlight: TColor);
|
|
|
|
begin
|
|
|
|
with Canvas do
|
|
|
|
begin
|
|
|
|
Pen.Color := Shadow;
|
|
|
|
PolyLine([Point(R.Left, R.Bottom), Point(R.Left, R.Top),
|
|
|
|
Point(R.Right, R.Top)]);
|
|
|
|
Pen.Color := Highlight;
|
|
|
|
PolyLine([Point(R.Right, R.Top), Point(R.Right, R.Bottom),
|
|
|
|
Point(R.Left, R.Bottom)]);
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
{=====}
|
|
|
|
|
|
|
|
function PointInRect(Point: TPoint; Rect: TRect): Boolean;
|
|
|
|
begin
|
|
|
|
result := (Point.X >= Rect.Left) and (Point.X <= Rect.Right)
|
|
|
|
and (Point.Y >= Rect.Top) and (Point.Y <= Rect.Bottom);
|
|
|
|
end;
|
|
|
|
{=====}
|
|
|
|
|
|
|
|
function DaysInMonth(Year, Month : Integer) : Integer;
|
|
|
|
begin
|
|
|
|
if (Year < 100) then
|
|
|
|
raise EVpDateException.Create(RSInvalidYear + ' "' + IntToStr(Year) + '"');
|
|
|
|
case Month of
|
|
|
|
1, 3, 5, 7, 8, 10, 12 : Result := 31;
|
|
|
|
4, 6, 9, 11 : Result := 30;
|
|
|
|
2 : Result := 28+Ord(IsLeapYear(Year));
|
|
|
|
else
|
|
|
|
Result := 0;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
{=====}
|
|
|
|
|
|
|
|
function DefaultEpoch : Integer;
|
|
|
|
var
|
|
|
|
ThisYear : Word;
|
|
|
|
ThisMonth : Word;
|
|
|
|
ThisDay : Word;
|
|
|
|
begin
|
|
|
|
DecodeDate(SysUtils.Date, ThisYear, ThisMonth, ThisDay);
|
|
|
|
Result := (ThisYear div 100) * 100;
|
|
|
|
end;
|
|
|
|
{=====}
|
2016-07-12 18:00:32 +00:00
|
|
|
(*
|
2008-02-03 12:05:55 +00:00
|
|
|
function GetLeftButton : Byte;
|
|
|
|
const
|
|
|
|
RLButton : array[Boolean] of Word = (VK_LBUTTON, VK_RBUTTON);
|
|
|
|
begin
|
|
|
|
//TODO: Result := RLButton[GetSystemMetrics(SM_SWAPBUTTON) <> 0];
|
2016-07-12 18:00:32 +00:00
|
|
|
end; *)
|
2008-02-03 12:05:55 +00:00
|
|
|
{=====}
|
|
|
|
|
|
|
|
procedure GetRGB(Clr : TColor; var IR, IG, IB : Byte);
|
|
|
|
begin
|
|
|
|
IR := GetRValue(Clr);
|
|
|
|
IG := GetGValue(Clr);
|
|
|
|
IB := GetBValue(Clr);
|
|
|
|
end;
|
|
|
|
{=====}
|
|
|
|
|
|
|
|
function IsLeapYear(Year : Integer) : Boolean;
|
|
|
|
begin
|
|
|
|
Result := (Year mod 4 = 0) and (Year mod 4000 <> 0) and
|
|
|
|
((Year mod 100 <> 0) or (Year mod 400 = 0));
|
|
|
|
end;
|
|
|
|
{=====}
|
|
|
|
|
|
|
|
function GetStartOfWeek(Date: TDateTime; StartOn: TVpDayType): TDateTime;
|
|
|
|
begin
|
|
|
|
result := Date;
|
|
|
|
case StartOn of
|
|
|
|
dtSunday: result := Date - (DayOfWeek(Date) - 1);
|
|
|
|
dtMonday: result := Date - (DayOfWeek(Date) - 2);
|
|
|
|
dtTuesday: result := Date - (DayOfWeek(Date) - 3);
|
|
|
|
dtWednesday: result := Date - (DayOfWeek(Date) - 4);
|
|
|
|
dtThursday: result := Date - (DayOfWeek(Date) - 5);
|
|
|
|
dtFriday: result := Date - (DayOfWeek(Date) - 6);
|
|
|
|
dtSaturday: result := Date - (DayOfWeek(Date) - 7);
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
{=====}
|
|
|
|
|
|
|
|
|
2016-06-24 20:00:32 +00:00
|
|
|
{$IFDEF DELPHI} {$IFNDEF Delphi6}
|
2016-07-04 19:00:42 +00:00
|
|
|
function MonthOfTheYear(TheDate: TDateTime): Word;
|
2008-02-03 12:05:55 +00:00
|
|
|
var
|
|
|
|
Year, Day: Word;
|
|
|
|
begin
|
2016-07-04 19:00:42 +00:00
|
|
|
DecodeDate(TheDate, Year, Result, Day);
|
2008-02-03 12:05:55 +00:00
|
|
|
end;
|
|
|
|
{=====}
|
|
|
|
|
2016-07-04 19:00:42 +00:00
|
|
|
procedure IncAMonth(var Year, Month, Day: Word; NumMonths: Integer);
|
2008-02-03 12:05:55 +00:00
|
|
|
type
|
|
|
|
PMonthDayTable = ^TMonthDayTable;
|
|
|
|
TMonthDayTable = array[1..12] of Word;
|
|
|
|
const
|
2016-07-04 19:00:42 +00:00
|
|
|
MonthDays: array[Boolean] of TMonthDayTable =
|
2008-02-03 12:05:55 +00:00
|
|
|
((31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31),
|
|
|
|
(31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31));
|
|
|
|
var
|
|
|
|
DayTable: PDayTable;
|
|
|
|
Sign: Integer;
|
|
|
|
begin
|
|
|
|
if NumMonths >= 0 then
|
|
|
|
Sign := 1
|
|
|
|
else
|
|
|
|
Sign := -1;
|
2016-07-04 19:00:42 +00:00
|
|
|
Year := Year + NumMonths div 12;
|
2008-02-03 12:05:55 +00:00
|
|
|
NumMonths := NumMonths mod 12;
|
|
|
|
Inc (Month, NumMonths);
|
2016-07-04 19:00:42 +00:00
|
|
|
if Word(Month-1) > 11 then
|
2008-02-03 12:05:55 +00:00
|
|
|
begin
|
2016-07-04 19:00:42 +00:00
|
|
|
Inc(Year, Sign);
|
|
|
|
Inc(Month, -12 * Sign);
|
2008-02-03 12:05:55 +00:00
|
|
|
end;
|
2016-07-04 19:00:42 +00:00
|
|
|
DayTable := @MonthDays[IsLeapYear(Year)];
|
2008-02-03 12:05:55 +00:00
|
|
|
if Day > DayTable^[Month] then
|
|
|
|
Day := DayTable^[Month];
|
|
|
|
end;
|
|
|
|
{=====}
|
|
|
|
|
2016-07-04 19:00:42 +00:00
|
|
|
function IncMonth(const TheDate: TDateTime; NumberOfMonths: Integer): TDateTime;
|
2008-02-03 12:05:55 +00:00
|
|
|
var
|
2016-07-04 19:00:42 +00:00
|
|
|
Year, Month, Day: Word;
|
2008-02-03 12:05:55 +00:00
|
|
|
begin
|
2016-07-04 19:00:42 +00:00
|
|
|
DecodeDate(TheDate, Year, Month, Day);
|
|
|
|
IncAMonth(Year, Month, Day, NumberOfMonths);
|
|
|
|
Result := EncodeDate(Year, Month, Day);
|
2008-02-03 12:05:55 +00:00
|
|
|
end;
|
|
|
|
{=====}
|
|
|
|
|
2016-07-04 19:00:42 +00:00
|
|
|
function IncYea (TheDate: TDateTime; NumYear : Integer) : TDateTime;
|
|
|
|
begin
|
|
|
|
Result := IncMont (TheDate, NumYears * 12);
|
|
|
|
end;
|
|
|
|
|
|
|
|
function DateOf(ADateTime: TDateTime): TDateTime;
|
2008-02-03 12:05:55 +00:00
|
|
|
begin
|
2016-07-04 19:00:42 +00:00
|
|
|
Result := trunc(ADateTime);
|
2008-02-03 12:05:55 +00:00
|
|
|
end;
|
2016-07-04 19:00:42 +00:00
|
|
|
|
|
|
|
function TimeOf(ADateTime: TDateTime): TDateTime;
|
|
|
|
begin
|
|
|
|
Result := frac(ADateTime);
|
|
|
|
end;
|
|
|
|
|
2008-02-03 12:05:55 +00:00
|
|
|
{=====}
|
2016-06-24 20:00:32 +00:00
|
|
|
{$ENDIF}{$ENDIF}
|
2008-02-03 12:05:55 +00:00
|
|
|
|
|
|
|
function GetJulianDate(Date: TDateTime): Word;
|
|
|
|
var
|
|
|
|
y, m, d, I: word;
|
|
|
|
Julian: Word;
|
|
|
|
begin
|
|
|
|
Julian := 0;
|
|
|
|
DecodeDate(Date, y, m, d);
|
|
|
|
|
|
|
|
{ Inc Julian by the number of days in each of the elapsed months }
|
|
|
|
for I := 1 to M do
|
|
|
|
Inc(Julian, DaysInMonth(Y, I));
|
|
|
|
|
|
|
|
{ add in the elapsed days from this month }
|
|
|
|
Julian := Julian + D;
|
|
|
|
|
|
|
|
{ return the value }
|
|
|
|
result := Julian;
|
|
|
|
end;
|
|
|
|
{=====}
|
|
|
|
|
2016-08-08 18:29:24 +00:00
|
|
|
function GetTimeFormat: TVpTimeFormat;
|
|
|
|
var
|
|
|
|
s: String;
|
2016-09-12 22:25:34 +00:00
|
|
|
p: Integer;
|
2016-08-08 18:29:24 +00:00
|
|
|
begin
|
|
|
|
s := lowercase(FormatDateTime('hh:nn ampm', 0.25));
|
2016-09-12 22:25:34 +00:00
|
|
|
p := pos(lowercase(FormatSettings.TimeAMString), s);
|
|
|
|
if p = Length(s) - Length(FormatSettings.TimeAMString) then
|
|
|
|
Result := tf12Hour
|
|
|
|
else
|
2016-08-08 18:29:24 +00:00
|
|
|
Result := tf24Hour;
|
|
|
|
end;
|
|
|
|
|
2016-09-12 22:25:34 +00:00
|
|
|
function GetTimeFormatStr(ATimeFormat: TVpTimeFormat): String;
|
|
|
|
begin
|
|
|
|
case ATimeFormat of
|
|
|
|
tf12Hour: Result := 'hh:nn am/pm';
|
|
|
|
tf24Hour: Result := 'hh:nn';
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
2016-07-05 22:21:02 +00:00
|
|
|
function GranularityToStr(Gran: TVpGranularity): string;
|
|
|
|
begin
|
|
|
|
Result := IntToStr(GranularityMinutes[Gran]);
|
|
|
|
end;
|
|
|
|
|
|
|
|
function HourToAMPM(Hour: TVpHours): string;
|
|
|
|
begin
|
|
|
|
if (Hour >= H_00) and (Hour <= H_11) then
|
|
|
|
Result := 'AM'
|
|
|
|
else
|
|
|
|
Result := 'PM';
|
|
|
|
end;
|
|
|
|
|
2016-06-20 11:00:59 +00:00
|
|
|
function HourToLine(const Value: TVpHours; const Granularity: TVpGranularity): Integer;
|
2008-02-03 12:05:55 +00:00
|
|
|
begin
|
2016-06-20 11:00:59 +00:00
|
|
|
Result := Ord(Value) * 60 div GranularityMinutes[Granularity];
|
2008-02-03 12:05:55 +00:00
|
|
|
end;
|
2016-07-05 22:21:02 +00:00
|
|
|
|
|
|
|
function HourToStr(Hour: TVpHours; Mil: Boolean): string;
|
|
|
|
begin
|
|
|
|
if Mil then
|
|
|
|
Result := IntToStr(ord(Hour))
|
|
|
|
else
|
|
|
|
if ord(Hour) mod 12 = 0 then
|
|
|
|
Result := '12'
|
|
|
|
else
|
|
|
|
Result := IntToStr(ord(Hour) mod 12);
|
|
|
|
end;
|
2008-02-03 12:05:55 +00:00
|
|
|
|
2016-06-20 11:00:59 +00:00
|
|
|
function GetStartLine(StartTime: TDateTime; Granularity: TVpGranularity): Integer;
|
2008-02-03 12:05:55 +00:00
|
|
|
var
|
2016-07-01 13:21:43 +00:00
|
|
|
LineDuration: Double; // percentage of a day covered by each line
|
2016-06-20 11:00:59 +00:00
|
|
|
Time: Double;
|
2008-02-03 12:05:55 +00:00
|
|
|
begin
|
|
|
|
{ remove the date part, and add one minute to the time }
|
2016-07-04 19:00:42 +00:00
|
|
|
Time := TimeOf(StartTime) + OneMinute;
|
2016-06-20 11:00:59 +00:00
|
|
|
LineDuration := GranularityMinutes[Granularity] / MinutesInDay;
|
2008-02-03 12:05:55 +00:00
|
|
|
result := trunc(Time / LineDuration);
|
|
|
|
end;
|
|
|
|
{=====}
|
|
|
|
|
2016-06-20 11:00:59 +00:00
|
|
|
function GetEndLine(EndTime: TDateTime; Granularity: TVpGranularity): Integer;
|
2008-02-03 12:05:55 +00:00
|
|
|
var
|
2016-07-01 13:21:43 +00:00
|
|
|
LineDuration: Double; // percentage of a day covered by each line
|
2016-06-20 11:00:59 +00:00
|
|
|
Time: Double;
|
2008-02-03 12:05:55 +00:00
|
|
|
begin
|
|
|
|
{ remove the date part, and subtract one minute from the time }
|
2016-07-04 19:00:42 +00:00
|
|
|
Time := TimeOf(EndTime) - OneMinute;
|
2016-06-20 11:00:59 +00:00
|
|
|
LineDuration := GranularityMinutes[Granularity] / MinutesInDay;
|
2008-02-03 12:05:55 +00:00
|
|
|
result := trunc(Time / LineDuration);
|
|
|
|
end;
|
|
|
|
{=====}
|
|
|
|
|
|
|
|
function GetAlarmAdvanceTime(Advance: Integer;
|
|
|
|
AdvanceType: TVpAlarmAdvType): TDateTime;
|
|
|
|
begin
|
|
|
|
result := 0.0;
|
|
|
|
case AdvanceType of
|
2016-07-04 19:00:42 +00:00
|
|
|
atMinutes : result := Advance * OneMinute;
|
|
|
|
atHours : result := Advance * OneHour;
|
2008-02-03 12:05:55 +00:00
|
|
|
atDays : result := Advance;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
{=====}
|
|
|
|
|
2016-06-30 21:29:02 +00:00
|
|
|
function DateInRange(ADate, StartDate, EndDate: TDateTime;
|
2016-07-04 19:21:55 +00:00
|
|
|
IncludeLimits: Boolean): Boolean;
|
2016-06-30 21:29:02 +00:00
|
|
|
begin
|
|
|
|
ADate := trunc(ADate);
|
|
|
|
StartDate := trunc(StartDate);
|
|
|
|
EndDate := trunc(EndDate);
|
|
|
|
Result := (StartDate < ADate) and (ADate < EndDate);
|
2016-07-04 19:21:55 +00:00
|
|
|
if IncludeLimits and (not Result) then
|
2016-06-30 21:29:02 +00:00
|
|
|
Result := (StartDate = ADate) or (EndDate = ADate);
|
|
|
|
end;
|
|
|
|
|
|
|
|
function TimeInRange(ATime, StartTime, EndTime: TDateTime;
|
2016-07-04 19:21:55 +00:00
|
|
|
IncludeLimits: Boolean): Boolean;
|
2016-06-14 14:20:23 +00:00
|
|
|
var
|
|
|
|
equStart, equEnd: Boolean;
|
2008-02-03 12:05:55 +00:00
|
|
|
begin
|
2016-06-30 21:29:02 +00:00
|
|
|
equStart := abs(ATime - StartTime) < CompareTimeEps;
|
|
|
|
equEnd := abs(ATime - EndTime) < CompareTimeEps;
|
2016-06-14 14:20:23 +00:00
|
|
|
|
2016-07-04 19:21:55 +00:00
|
|
|
if IncludeLimits then
|
2016-06-30 21:29:02 +00:00
|
|
|
Result := equStart or equEnd or ((ATime > StartTime) and (ATime < EndTime))
|
2008-02-03 12:05:55 +00:00
|
|
|
else
|
2016-06-30 21:29:02 +00:00
|
|
|
Result := (not equStart) and (not equEnd) and (ATime > StartTime) and (ATime < EndTime);
|
2008-02-03 12:05:55 +00:00
|
|
|
end;
|
|
|
|
{=====}
|
|
|
|
|
|
|
|
function LineToStartTime(Line: Integer; Granularity: TVpGranularity): TDateTime;
|
|
|
|
begin
|
2016-06-20 11:00:59 +00:00
|
|
|
Result := frac(Line * GranularityMinutes[Granularity] / MinutesInDay);
|
2008-02-03 12:05:55 +00:00
|
|
|
end;
|
|
|
|
{=====}
|
|
|
|
|
|
|
|
function GetLineDuration(Granularity: TVpGranularity): Double;
|
|
|
|
begin
|
2016-06-20 11:00:59 +00:00
|
|
|
Result := GranularityMinutes[Granularity] / MinutesInDay;
|
2008-02-03 12:05:55 +00:00
|
|
|
end;
|
|
|
|
{=====}
|
|
|
|
|
2016-07-21 11:15:26 +00:00
|
|
|
function AutoHeight(ARadioGroup: TRadioGroup): Integer;
|
|
|
|
var
|
|
|
|
w: Integer;
|
|
|
|
begin
|
|
|
|
w := ARadioGroup.Width;
|
|
|
|
ARadioGroup.AutoSize := true;
|
|
|
|
Result := ARadioGroup.Height;
|
|
|
|
ARadioGroup.AutoSize := false;
|
|
|
|
ARadioGroup.Width := w;
|
|
|
|
end;
|
|
|
|
|
2016-06-20 11:00:59 +00:00
|
|
|
function GetLabelWidth(ALabel: TLabel): Integer;
|
2016-06-10 16:12:14 +00:00
|
|
|
var
|
|
|
|
canvas: TControlCanvas;
|
|
|
|
begin
|
|
|
|
canvas := TControlCanvas.Create;
|
|
|
|
canvas.Control := ALabel;
|
2016-07-14 09:40:54 +00:00
|
|
|
canvas.Font.Assign(ALabel.Font);
|
2016-06-10 16:12:14 +00:00
|
|
|
Result := canvas.TextWidth(ALabel.Caption);
|
|
|
|
canvas.Free;
|
|
|
|
end;
|
|
|
|
|
2016-07-14 12:20:59 +00:00
|
|
|
function GetButtonWidth(AButton: TButton): Integer;
|
|
|
|
const
|
2016-07-15 23:25:07 +00:00
|
|
|
MARGIN = 24;
|
2016-07-14 12:20:59 +00:00
|
|
|
var
|
|
|
|
canvas: TControlCanvas;
|
|
|
|
begin
|
|
|
|
canvas := TControlCanvas.Create;
|
|
|
|
canvas.Control := AButton;
|
|
|
|
canvas.Font.Assign(AButton.Font);
|
2016-07-15 23:25:07 +00:00
|
|
|
Result := canvas.TextWidth(AButton.Caption) + MARGIN * Screen.PixelsPerInch div DesignTimeDPI;
|
2016-08-26 13:33:45 +00:00
|
|
|
canvas.Free;
|
2016-07-14 12:20:59 +00:00
|
|
|
end;
|
|
|
|
|
2016-07-02 22:46:05 +00:00
|
|
|
function GetRealFontHeight(AFont: TFont): Integer;
|
|
|
|
begin
|
|
|
|
if AFont.Size = 0 then
|
2016-07-12 18:00:32 +00:00
|
|
|
{$IFDEF LCL}
|
2016-07-14 09:40:54 +00:00
|
|
|
Result := GetFontData(AFont.Reference.Handle).Height * Screen.PixelsPerInch div DesignTimeDPI
|
2016-07-12 18:00:32 +00:00
|
|
|
{$ELSE}
|
|
|
|
Result := GetFontData(AFont.Handle).Height
|
|
|
|
{$ENDIF}
|
|
|
|
else
|
2016-07-02 22:46:05 +00:00
|
|
|
Result := AFont.Height;
|
|
|
|
end;
|
|
|
|
|
2016-07-07 20:51:29 +00:00
|
|
|
function RightOf(AControl: TControl): Integer;
|
|
|
|
begin
|
|
|
|
Result := AControl.Left + AControl.Width;
|
|
|
|
end;
|
|
|
|
|
2016-07-13 22:58:32 +00:00
|
|
|
function Bottomof(AControl: TControl): Integer;
|
|
|
|
begin
|
|
|
|
Result := AControl.Top + AControl.Height;
|
|
|
|
end;
|
|
|
|
|
2016-06-24 10:33:55 +00:00
|
|
|
function SameDate(dt1, dt2: TDateTime): Boolean;
|
|
|
|
begin
|
|
|
|
Result := trunc(dt1) = trunc(dt2);
|
|
|
|
end;
|
|
|
|
|
2016-06-24 20:03:19 +00:00
|
|
|
// Calculates ISO week number (checked with Jan 1, 2016, which is in week 53).
|
2016-06-24 14:16:51 +00:00
|
|
|
function GetWeekOfYear(ADate: TDateTime): byte;
|
2016-06-24 20:03:19 +00:00
|
|
|
// was in TvWeekView.
|
2016-06-24 14:16:51 +00:00
|
|
|
var
|
|
|
|
yr, dummy: word;
|
|
|
|
First: TDateTime;
|
|
|
|
begin
|
|
|
|
DecodeDate(ADate + (8 - DayOfWeek(ADate)) mod 7 - 3, yr, dummy,dummy);
|
|
|
|
First := EncodeDate(yr, 1, 1);
|
2016-06-24 20:03:19 +00:00
|
|
|
Result := trunc(ADate - First - 3 + (DayOfWeek(First) + 1) mod 7) div 7 + 1;
|
2016-06-24 14:16:51 +00:00
|
|
|
end;
|
|
|
|
|
2016-07-04 21:35:15 +00:00
|
|
|
// Returns true if the specified date is on the weekend.
|
|
|
|
function IsWeekend(ADate: TDateTime): Boolean;
|
|
|
|
begin
|
|
|
|
Result := (DayOfWeek(ADate) in [1, 7]);
|
|
|
|
end;
|
|
|
|
|
2016-06-27 22:43:15 +00:00
|
|
|
function DecodeLineEndings(const AText: String): String;
|
|
|
|
begin
|
2016-06-28 10:18:32 +00:00
|
|
|
Result := StringReplace(AText, '\n', LineEnding, [rfReplaceAll]);
|
2016-06-27 22:43:15 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
function EncodeLineEndings(const AText: String): String;
|
|
|
|
begin
|
2016-06-28 10:18:32 +00:00
|
|
|
Result := StringReplace(AText, LineEnding, '\n', [rfReplaceAll]);
|
2016-06-27 22:43:15 +00:00
|
|
|
end;
|
2016-06-24 14:16:51 +00:00
|
|
|
|
2016-09-11 17:53:51 +00:00
|
|
|
function StripLastLineEnding(const AText: String): String;
|
|
|
|
begin
|
|
|
|
Result := AText;
|
|
|
|
while (Length(Result) > 0) and (Result[Length(Result)] in [#10, #13]) do
|
|
|
|
Delete(Result, Length(Result), 1);
|
|
|
|
end;
|
|
|
|
|
2016-09-10 17:26:42 +00:00
|
|
|
procedure AddResourceGroupMenu(AMenu: TMenuItem; AResource: TVpResource;
|
|
|
|
AEventHandler: TNotifyEvent);
|
|
|
|
var
|
|
|
|
datastore: TVpCustomDatastore;
|
|
|
|
grp: TVpResourceGroup;
|
|
|
|
list: TList;
|
|
|
|
newItem: TMenuItem;
|
|
|
|
newSubItem: TMenuItem;
|
|
|
|
i: Integer;
|
|
|
|
begin
|
|
|
|
if (AMenu = nil) or (AResource = nil) or (AResource.Owner = nil) then
|
|
|
|
exit;
|
|
|
|
|
|
|
|
datastore := AResource.Owner.Owner as TVpCustomDatastore;
|
|
|
|
|
|
|
|
if (RSPopupResourceGroups <> '') and
|
|
|
|
(datastore <> nil) and (datastore.Resource <> nil) then
|
|
|
|
begin
|
|
|
|
list := TList.Create;
|
|
|
|
try
|
|
|
|
datastore.Resource.GetResourceGroups(list);
|
|
|
|
if list.Count > 0 then begin
|
|
|
|
newItem := TMenuItem.Create(AMenu.Owner);
|
|
|
|
newItem.Caption := RSPopupResourceGroups;
|
|
|
|
newItem.Tag := 0;
|
|
|
|
AMenu.Add(newItem);
|
|
|
|
|
|
|
|
newSubItem := TMenuItem.Create(AMenu.Owner);
|
2016-09-10 20:26:10 +00:00
|
|
|
newSubItem.Caption := RSNoOverlayedEvents;
|
2016-09-10 17:26:42 +00:00
|
|
|
newSubItem.OnClick := AEventHandler;
|
|
|
|
newSubItem.GroupIndex := 1;
|
|
|
|
newSubItem.AutoCheck := true;
|
2016-09-10 18:27:50 +00:00
|
|
|
newSubItem.Checked := datastore.Resource.Group = nil;
|
2016-09-10 17:26:42 +00:00
|
|
|
newSubItem.Tag := 0;
|
|
|
|
newItem.Add(newSubItem);
|
|
|
|
|
|
|
|
if list.Count > 1 then begin
|
|
|
|
newSubItem := TMenuItem.Create(AMenu.Owner);
|
|
|
|
newSubItem.Caption := '-';
|
|
|
|
newItem.Add(newSubItem);
|
|
|
|
end;
|
|
|
|
|
|
|
|
for i:=0 to list.Count-1 do begin
|
|
|
|
grp := TVpResourceGroup(list[i]);
|
|
|
|
newSubItem := TMenuItem.Create(AMenu.Owner);
|
|
|
|
newSubItem.Caption := grp.Caption;
|
|
|
|
newSubItem.OnClick := AEventHandler;
|
|
|
|
newSubItem.GroupIndex := 1;
|
|
|
|
newSubItem.AutoCheck := true;
|
2016-09-10 18:27:50 +00:00
|
|
|
newSubItem.Checked := (datastore.Resource.Group = grp);
|
2016-09-10 17:26:42 +00:00
|
|
|
newSubItem.Tag := PtrInt(grp);
|
|
|
|
newItem.Add(NewSubItem);
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
finally
|
|
|
|
list.Free;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
2016-09-10 20:08:06 +00:00
|
|
|
function OverlayPatternToBrushStyle(APattern: TVpOverlayPattern): TBrushStyle;
|
|
|
|
begin
|
|
|
|
Result := TBrushStyle(APattern);
|
|
|
|
end;
|
|
|
|
|
2016-07-14 09:40:54 +00:00
|
|
|
{$IFDEF LCL}
|
|
|
|
procedure HighDPI(FromDPI: integer);
|
|
|
|
var
|
|
|
|
i: integer;
|
|
|
|
begin
|
|
|
|
if Screen.PixelsPerInch = FromDPI then
|
|
|
|
exit;
|
|
|
|
|
|
|
|
for i := 0 to Screen.FormCount - 1 do
|
|
|
|
ScaleDPI(Screen.Forms[i], FromDPI);
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure ScaleDPI(Control: TControl; FromDPI: integer);
|
|
|
|
var
|
|
|
|
i: integer;
|
|
|
|
WinControl: TWinControl;
|
|
|
|
begin
|
|
|
|
if Screen.PixelsPerInch = FromDPI then
|
|
|
|
exit;
|
|
|
|
|
|
|
|
with Control do
|
|
|
|
begin
|
|
|
|
Left := ScaleX(Left, FromDPI);
|
|
|
|
Top := ScaleY(Top, FromDPI);
|
|
|
|
Width := ScaleX(Width, FromDPI);
|
|
|
|
Height := ScaleY(Height, FromDPI);
|
|
|
|
end;
|
|
|
|
|
|
|
|
if Control is TWinControl then
|
|
|
|
begin
|
|
|
|
WinControl := TWinControl(Control);
|
|
|
|
if WinControl.ControlCount = 0 then
|
|
|
|
exit;
|
|
|
|
for i := 0 to WinControl.ControlCount - 1 do
|
|
|
|
ScaleDPI(WinControl.Controls[i], FromDPI);
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
{$ENDIF}
|
|
|
|
|
2016-07-12 09:26:14 +00:00
|
|
|
{$PUSH}{$HINTS OFF}
|
|
|
|
procedure Unused(const A1);
|
|
|
|
begin
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure Unused(const A1, A2);
|
|
|
|
begin
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure Unused(const A1, A2, A3);
|
|
|
|
begin
|
|
|
|
end;
|
|
|
|
{$POP}
|
|
|
|
|
2008-02-03 12:05:55 +00:00
|
|
|
end.
|