Автор: VadimLou
Дата сообщения: 29.09.2005 16:58
Исправления для DevEx от 26 августа 2005 от траблов работы с датами (и немного другого):
"ExpressDataController"
cxVariants.pas
function VarIsSoftNull(const AValue: Variant): Boolean;
begin
{+}
// Result := VarIsNull(AValue) or
// ({(VarType(AValue) = varString)}VarIsStr(AValue) and (AValue = ''));
Result := VarIsEmpty(AValue) or VarIsNull(AValue) or
({(VarType(AValue) = varString)}VarIsStr(AValue) and (Trim(VarToStr(AValue)) = ''));
{+.}
end;
"ExpressEditors Library 5"
cxCalendar.pas
procedure TcxCustomDateEditProperties.PrepareDisplayValue(
const AEditValue: TcxEditValue; var DisplayValue: TcxEditValue;
AEditFocused: Boolean);
function GetDisplayValue: string;
var
AValue: TcxEditValue;
begin
{+}
//if VarIsSoftNull(AEditValue) or (AEditValue = NullDate) then
// Result := GetEmptyDisplayValue(AEditFocused)
if VarIsSoftNull(AEditValue) or ( (VarIsDate(AEditValue) or VarIsNumericEx(AEditValue))
and (AEditValue = NullDate)) then
begin
Result := GetEmptyDisplayValue(AEditFocused);
end
{+.}
else
if not(VarIsStr(AEditValue) or VarIsDate(AEditValue) or VarIsNumericEx(AEditValue)) then
...
cxCurrencyEdit.pas
procedure TcxCustomCurrencyEdit.KeyPress(var Key: Char);
begin
{+}
if not (ActiveProperties.UseThousandSeparator and (Key = ThousandSeparator)) and
{$IFNDEF CLR}(Key in ['.', ',']){$ELSE}((Key = '.') or (Key = ',')){$ENDIF} then
Key := DecimalSeparator{$IFDEF CLR}[1]{$ENDIF};
inherited KeyPress(Key);
{+.}
end;
cxDateUtils.pas
function TextToDateEx(AText: string; var ADate: TDateTime): Boolean;
var
ADay, AMonth, AYear: Word;
{+}
sBaseText: string;
{+.}
begin
try
AText := Trim(AText);
if AText = '' then
Result := False
else
begin
{+}
sBaseText := AText;
{+.}
if not cxFormatController.UseDelphiDateTimeFormats then
CorrectTextForOleDateTimeConversion(AText);
// Smart Date
if not SmartTextToDate(AText, ADate) then
if cxFormatController.UseDelphiDateTimeFormats then
// В режиме cxFormats.pas:TcxFormatController.UseDelphiDateTimeFormats == True
// в Delphi 5 работать не будет, т.к. нужно делать испрвления в системной библиотеке.
// На других Delphi этот режим не проверял. По умолчанию этот режим не используется.
ADate := StrToDateTime(AText)
else
{+}
//ADate := VarToDateTime(AText);
if not cxStrToDateTime(AText, True, ADate) then
ADate := VarToDateTime(sBaseText);
{+.}
Result := (ADate < MaxInt) and (ADate > -MaxInt - 1);
if Result then
begin
DecodeDate(ADate, AYear, AMonth, ADay);
Result := (ADay > 0) and (AYear <= MaxYear);
end;
end;
except
Result := False;
ADate := NullDate;
end;
end;
// Для .NET
function TextToDateEx(AText: string; var ADate: TDateTime): Boolean;
var
ADay, AMonth, AYear: Word;
{+}
sBaseText: string;
{+.}
begin
try
AText := Trim(AText);
if AText = '' then
Result := False
else
begin
{+}
sBaseText := AText;
{+.}
if not cxFormatController.UseDelphiDateTimeFormats then
CorrectTextForOleDateTimeConversion(AText);
// Smart Date
if not SmartTextToDate(AText, ADate) then
if cxFormatController.UseDelphiDateTimeFormats then
ADate := StrToDateTime(AText)
else
{+}
//ADate := TDateTime.Parse(AText);
if not cxStrToDateTime(AText, True, ADate) then
ADate := TDateTime.Parse(AText);
{+.}
Result := True;
if Result then
begin
DecodeDate(ADate, AYear, AMonth, ADay);
Result := (ADay > 0) and (AYear <= MaxYear);
end;
end;
except
Result := False;
ADate := NullDate;
end;
end;
"ExpressLibrary"
cxContainer.pas
procedure TcxCustomPopupWindow.Popup(AFocusedControl: TWinControl);
...
procedure ShowPopupWindow;
var
P: TPoint;
begin
InitPopup;
...
if FFocusedControl = nil then
SetFocus
else {+} if FFocusedControl.CanFocus then {+.}
FFocusedControl.SetFocus;
...