📄 jfedit.pas
字号:
Key := #0;
Exit;
end;
end;
end;
if FJFInputChars <> '' then
begin
for iLoop := 1 to Length(FJFInputChars) do
begin
if Ord(Key) = Ord(FJFInputChars[iLoop]) then
begin
Exit;
end;
end;
Key := #0;
Exit;
end;
end;
JFbkDropDown,
JFbkDropDownTree : begin
if Key in ['0'..'9'] then
begin
StartTimer;
if not FTimer.Suspended then
begin
FInputKeys := FInputKeys + Key;
Key := #0;
end;
end;
end;
end;
end;
procedure TJFEdit.KeyUp(var Key: Word; Shift: TShiftState);
begin
inherited;
end;
procedure TJFEdit.Clear;
begin
FJFSelectResult.Clear;
FJFNumericValue := 0;
FJFDateValue := Now;
inherited Clear;
end;
procedure TJFEdit.SetBeforeShowSelect(const Value: TEdtBeforeShowSelect);
begin
FBeforeShowSelect := Value;
end;
procedure TJFEdit.ShowSelect(Key: Char);
var
Allow: Boolean;
SelectParams: PJFSelectParams;
iLoop: Integer;
AFormClass: TFormClass;
AForm : TForm;
begin
Allow := True;
if Assigned(FBeforeShowSelect) then
begin
FBeforeShowSelect(Allow);
if not Allow then
Exit;
end;
case FJFEditKind of
JFbkNumeric : AFormClass := TFormClass(GetClass('TfrmJFCalculator'));
JFbkDropDown,
JFbkDropDownTree : AFormClass := TFormClass(GetClass('TfrmJFDropDown'));
JFbkDate : AFormClass := TFormClass(GetClass('TfrmJFCalendar'));
JFbkSearch : AFormClass := TFormClass(GetClass('TfrmJFSearch'));
end;
if not Assigned(AFormClass) then
begin
Exit;
end;
New(SelectParams);
SelectParams^ := GetJFSelectParams(Key);
AForm := AFormClass.Create(nil);
PostMessage(AForm.Handle, JF_MSG_SHOW_SELECT, LongInt(FJFDropDownList), LongInt(SelectParams));
end;
procedure TJFEdit.SetJFDateValue(const Value: TDateTime);
var
DispText: string;
begin
FJFDateValue := Value;
DispText := FormatDateTime(JFFormatSettings.ShortDateFormat + ' ' +
JFFormatSettings.ShortTimeFormat, FJFDateValue);
if FJFTimeVisible then
begin
if not FJFSecVisible then
DispText := Copy(DispText, 1, 16);
end
else
DispText := Copy(DispText, 1, 10);
inherited Text := DispText;
end;
procedure TJFEdit.SetJFNumericValue(const Value: Extended);
var
LFactor: Extended;
iSelStart : Integer;
iSelLength: Integer;
begin
FJFNumericValue := Value;
LFactor := IntPower(10, FJFDecimalDigits);
iSelStart := SelStart;
iSelLength:= SelLength;
try
FJFNumericValue := Trunc(FJFNumericValue * LFactor) / LFactor;
if FJFNumericLimit then
begin
if FJFNumericValue > FJFMaxNumeric then
begin
FJFNumericValue := Trunc(FJFMaxNumeric * LFactor) / LFactor;
Exit;
end;
if FJFNumericValue < FJFMinNumeric then
begin
FJFNumericValue := Trunc(FJFMinNumeric * LFactor) / LFactor;
Exit;
end;
end;
finally
if FJFEditKind = JFbkNumeric then
inherited Text := FloatToStr(FJFNumericValue);
SelStart := iSelStart;
SelLength:= iSelLength;
end;
end;
procedure TJFEdit.SetOnSelectReturn(const Value: TNotifyEvent);
begin
FOnSelectReturn := Value;
end;
procedure TJFEdit.SelectReturn(var MSG: TMessage);
var
ADate: string;
ATime: string;
ADateTime: TDateTime;
begin
case FJFEditKind of
JFbkNumeric : JFNumericValue := PExtended(MSG.LParam)^;
JFbkDate : begin
ADate := FormatDateTime(JFFormatSettings.ShortDateFormat,PDate(MSG.LParam)^);
ATime := FormatDateTime(JFFormatSettings.ShortTimeFormat, FJFDateValue);
if FJFTimeVisible then
ADateTime := StrToDateTime(ADate + ' ' + ATime, JFFormatSettings)
else
ADateTime := StrtoDateTime(ADate, JFFormatSettings);
JFDateValue := ADateTime;
end;
JFbkDropDown,
JFbkDropDownTree,
JFbkSearch : begin
FJFSelectResult.CopyRecord(TJFRecList(MSG.LParam));
SetDispText;
end;
end;
SelectAll;
if Assigned(FOnSelectReturn) then
FOnSelectReturn(Self);
if FJFSRFocusMove then
Perform(WM_KEYDOWN, VK_RETURN, 0);
end;
procedure TJFEdit.SetJFFilterChars(const Value: string);
begin
FJFFilterChars := Value;
if FJFEditKind = JFbkFilterChar then
Clear;
end;
procedure TJFEdit.SetJFFocusMove(const Value: Boolean);
begin
FJFFocusMove := Value;
end;
procedure TJFEdit.SetJFDecimalDigits(const Value: Integer);
begin
if Value < 0 then
Exit;
FJFDecimalDigits := Value;
JFNumericValue := FJFNumericValue;
end;
procedure TJFEdit.SetJFMaxNumeric(const Value: Extended);
begin
FJFMaxNumeric := Value;
end;
procedure TJFEdit.SetJFMinNumeric(const Value: Extended );
begin
FJFMinNumeric := Value;
end;
procedure TJFEdit.SetJFNumericLimit(const Value: Boolean);
begin
FJFNumericLimit := Value;
end;
function TJFEdit.GetText: string;
begin
Result := inherited Text;
end;
procedure TJFEdit.SetText(const Value: string);
begin
inherited Text := Value;
Change;
end;
procedure TJFEdit.SetJFInputChars(const Value: string);
begin
FJFInputChars := Value;
if FJFEditKind = JFbkFilterChar then
Clear;
end;
function TJFEdit.GetEditMask: TEditMask;
begin
Result := inherited EditMask;
end;
procedure TJFEdit.SetEditMask(const Value: TEditMask);
begin
if FJFEditKind = JFbkDate then
Exit;
inherited EditMask := Value;
end;
procedure TJFEdit.SetJFMsgClear(const Value: Boolean);
begin
FJFMsgClear := Value;
end;
procedure TJFEdit.MSGClear(var MSG: TMessage);
begin
if FJFMsgClear then
begin
Clear;
if (FJFEditKind = jfbkNumeric) and FJFNumericLimit then
begin
SetJFNumericValue(FJFMinNumeric);
end;
if (FJFEditKind = jfbkDropDown) or (FJFEditKind = jfbkDropDownTree) then
SetJFSelectIndex(FJFClearDefIndex);
end;
MSG.Result := 0;
end;
procedure TJFEdit.SetJFMultiSelect(const Value: Boolean);
begin
FJFMultiSelect := Value;
end;
procedure TJFEdit.SetJFDispFieldName(const Value: string);
begin
FJFDispFieldName := Value;
end;
function TJFEdit.IsSelectEmpty: Boolean;
begin
Result := FJFSelectResult.Count = 0;
end;
procedure TJFEdit.SetJFBackspaceClear(const Value: Boolean);
begin
FJFBackspaceClear := Value;
end;
procedure TJFEdit.SetJFListRowCount(const Value: Integer);
begin
if (Value <= 0) or (Value >= 50) then
Exit;
FJFListRowCount := Value;
end;
procedure TJFEdit.SetJFDispSeparator(const Value: string);
begin
FJFDispSeparator := Value;
end;
procedure TJFEdit.SetJFDDTItemID(const Value: string);
begin
FJFDDTItemID := Value;
end;
procedure TJFEdit.SetJFDDTParentID(const Value: string);
begin
FJFDDTParentID := Value;
end;
function TJFEdit.GetJFSelectParams(Key : Char): TJFSelectParams;
var
iLoop : Integer;
begin
Result.HostHandle := Handle;
Result.HostControl := Self;
Result.EditKind := FJFEditKind;
Result.FirstKeyChar := Key;
Result.SQLText := FJFSQLText;
Result.DateValue := FJFDateValue;
Result.NumericValue := FJFNumericValue;
Result.RemoteServer := FJFRemoteServer;
Result.MultiSelect := FJFMultiSelect;
Result.ListRowCount := FJFListRowCount;
Result.DDTItemID := FJFDDTItemID;
Result.DDTParentID := FJFDDTParentID;
Result.DispFieldName:= FJFDispFieldName;
Result.EnterToSearch:= FJFEnterToSearch;
Result.PacketRecords:= FJFPacketRecords;
Result.SearchUseLocate := FJFSearchUseLocate;
SetLength(Result.SearchFields, FJFSearchFields.Count);
for iLoop := 0 to FJFSearchFields.Count - 1 do
begin
Result.SearchFields[iLoop].FieldName := FJFSearchFields.Items[iLoop].FieldName;
Result.SearchFields[iLoop].FieldType := FJFSearchFields.Items[iLoop].FieldType;
Result.SearchFields[iLoop].Operation := FJFSearchFields.Items[iLoop].Operation;
Result.SearchFields[iLoop].FullBlur := FJFSearchFields.Items[iLoop].FullBlur;
end;
SetLength(Result.DispFields, FJFDispFields.Count);
for iLoop := 0 to FJFDispFields.Count - 1 do
begin
Result.DispFields[iLoop].FieldName := FJFDispFields.Items[iLoop].FieldName;
Result.DispFields[iLoop].Alignment := FJFDispFields.Items[iLoop].Alignment;
Result.DispFields[iLoop].DispWidth := FJFDispFields.Items[iLoop].DispWidth;
Result.DispFields[iLoop].ColumnTitle := FJFDispFields.Items[iLoop].ColumnTitle;
end;
SetLength(Result.ExecParams, FJFExecParams.Count);
for iLoop := 0 to FJFExecParams.Count - 1 do
begin
Result.ExecParams[iLoop] := FJFExecParams.Items[iLoop].Value;
end;
end;
function TJFEdit.GetDropDownList: Boolean;
var
AFormClass: TFormClass;
AForm : TForm;
JFSelectParams: PJFSelectParams;
MSGResult : LongInt;
begin
Result := False;
if (FJFEditKind <> JFbkDropDownTree) and
(FJFEditKind <> JFbkDropDown) then
Exit;
AFormClass := TFormClass(GetClass('TfrmJFDropDown'));
if not Assigned(AFormClass) then
Exit;
AForm := AFormClass.Create(nil);
try
New(JFSelectParams);
JFSelectParams^ := GetJFSelectParams(#0);
MSGResult := SendMessage(AForm.Handle, JF_MSG_GET_DROPDOWN_LIST, 0, LongInt(JFSelectParams));
if MSGResult = 0 then
Exit;
FJFDropDownList.AddRecrods(TDataSet(MSGResult));
finally
AForm.Free;
end;
Result := True;
end;
function TJFEdit.IsVaildDateTime: Boolean;
begin
Result := StrToDateTimeDef(inherited Text, JFErrDateTime, JFFormatSettings) <>
JFErrDateTime;
end;
procedure TJFEdit.SetDateTimeMask;
var
Mask : string;
begin
if FJFEditKind <> JFbkDate then
Exit;
Mask := '!9999-99-99 99:99:99;1;_';
if FJFTimeVisible then
begin
if not FJFSecVisible then
Mask := AnsiReplaceText(Mask, ':99;', ';');
end
else
Mask := AnsiReplaceText(Mask, ' 99:99:99', '');
inherited EditMask := Mask;
end;
procedure TJFEdit.SetJFSecVisible(const Value: Boolean);
begin
FJFSecVisible := Value;
SetDateTimeMask;
end;
procedure TJFEdit.SetJFTimeVisible(const Value: Boolean);
begin
FJFTimeVisible := Value;
SetDateTimeMask;
end;
procedure TJFEdit.SetDispText;
var
DispText : string;
iLoop : Integer;
begin
DispText := '';
if Trim(FJFDispFieldName) <> '' then
begin
for iLoop := 0 to FJFSelectResult.Count - 1 do
begin
if DispText <> '' then
DispText := DispText + FJFDispSeparator;
DispText := DispText + FJFSelectResult.GetFieldValue(FJFDispFieldName, '', iLoop);
end;
end;
inherited Text := DispText;
end;
procedure TJFEdit.SetJFSelectIndex(const Value: Integer);
begin
if (Value >= 0) and (Value <= FJFDropDownList.Count -1) then
begin
FJFSelectResult.Clear;
FJFSelectResult.AddFieldValues(PJFFieldValues(FJFDropDownList.Items[Value])^);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -