cxmemo.pas
来自「胜天进销存源码,国产优秀的进销存」· PAS 代码 · 共 2,016 行 · 第 1/4 页
PAS
2,016 行
if Focused and (ActiveProperties.MaxLength > 0) and
(Length(WideString(Copy(Text, 1, SelStart) + Value)) > ActiveProperties.MaxLength) then
begin
ANewValueLength := ActiveProperties.MaxLength - Length(WideString(Copy(Text, 1, SelStart)));
if ANewValueLength <= 0 then
Exit;
ANewValue := Copy(WideString(Value), 1, ANewValueLength);
end;
ACheckAsYouType := (Assigned(dxSpellCheckerEditHelper) and
dxSpellCheckerEditHelper.IsSpellCheckerDialogControl(GetFocus));
if (Focused or ACheckAsYouType) and not DoEditing then
Exit;
APrevKeyboardAction := KeyboardAction;
KeyboardAction := Focused or ACheckAsYouType;
try
InnerTextEdit.SelText := ANewValue;
InternalSynchronizeEditValue;
finally
KeyboardAction := APrevKeyboardAction;
end;
end;
function TcxCustomMemo.TabsNeeded: Boolean;
begin
Result := inherited TabsNeeded or ActiveProperties.WantTabs;
end;
procedure TcxCustomMemo.CreateParams(var Params: TCreateParams);
begin
inherited CreateParams(Params);
with Params.WindowClass do
begin
style := style and not CS_VREDRAW;
if (ActiveProperties.ScrollBars in [ssHorizontal, ssBoth]) or not ActiveProperties.WordWrap then
style := style and not CS_HREDRAW;
end;
end;
procedure TcxCustomMemo.WndProc(var Message: TMessage);
begin
inherited WndProc(Message);
case Message.Msg of
WM_NCCALCSIZE,
WM_WINDOWPOSCHANGED,
CM_WININICHANGE:
UpdateScrollBarsParameters;
end;
end;
function TcxCustomMemo.CanMemoKeyModifyEdit(Key: Word; Shift: TShiftState;
AIsKeyPress: Boolean): Boolean;
var
ATranslatedKey: Word;
begin
ATranslatedKey := TranslateKey(Key);
Result := (ATranslatedKey = VK_RETURN) and (ActiveProperties.WantReturns or
(ssCtrl in Shift));
Result := Result or (ATranslatedKey = VK_TAB) and
(ActiveProperties.WantTabs or AIsKeyPress);
end;
procedure TcxCustomMemo.InternalSynchronizeEditValue;
begin
if not KeyboardAction then
begin
ResetOnNewDisplayValue;
SynchronizeEditValue;
EditModified := False;
end;
end;
function TcxCustomMemo.GetActiveProperties: TcxCustomMemoProperties;
begin
Result := TcxCustomMemoProperties(InternalGetActiveProperties);
end;
function TcxCustomMemo.GetCaretPos: TPoint;
begin
Result := InnerMemo.CaretPos;
end;
function TcxCustomMemo.GetLines: TStrings;
begin
Result := InnerMemo.Lines;
end;
function TcxCustomMemo.GetInnerMemo: IcxInnerMemo;
begin
Result := InnerEdit as IcxInnerMemo;
end;
function TcxCustomMemo.GetProperties: TcxCustomMemoProperties;
begin
Result := TcxCustomMemoProperties(FProperties);
end;
procedure TcxCustomMemo.SetCaretPos(const Value: TPoint);
begin
InnerMemo.CaretPos := Value;
end;
procedure TcxCustomMemo.SetLines(Value: TStrings);
begin
InnerMemo.Lines.Assign(Value);
end;
procedure TcxCustomMemo.SetProperties(Value: TcxCustomMemoProperties);
begin
FProperties.Assign(Value);
end;
procedure TcxCustomMemo.WMCommand(var Message: TWMCommand);
begin
inherited;
if (Message.NotifyCode = EN_VSCROLL) or (Message.NotifyCode = EN_HSCROLL) then
SetScrollBarsParameters;
end;
{ TcxMemo }
class function TcxMemo.GetPropertiesClass: TcxCustomEditPropertiesClass;
begin
Result := TcxMemoProperties;
end;
function TcxMemo.GetActiveProperties: TcxMemoProperties;
begin
Result := TcxMemoProperties(InternalGetActiveProperties);
end;
function TcxMemo.GetProperties: TcxMemoProperties;
begin
Result := TcxMemoProperties(FProperties);
end;
procedure TcxMemo.SetProperties(Value: TcxMemoProperties);
begin
FProperties.Assign(Value);
end;
{ TcxFilterMemoHelper }
class function TcxFilterMemoHelper.GetSupportedFilterOperators(
AProperties: TcxCustomEditProperties;
AValueTypeClass: TcxValueTypeClass;
AExtendedSet: Boolean = False): TcxFilterControlOperators;
begin
Result := [fcoLike, fcoNotLike, fcoBlanks, fcoNonBlanks];
end;
{ TcxCustomInnerMemoHelper }
constructor TcxCustomInnerMemoHelper.Create(AEdit: TcxCustomInnerMemo);
begin
inherited Create(nil);
FEdit := AEdit;
end;
{ IcxContainerInnerControl }
function TcxCustomInnerMemoHelper.GetControlContainer: TcxContainer;
begin
Result := Edit.Container;
end;
function TcxCustomInnerMemoHelper.GetControl: TWinControl;
begin
Result := Edit;
end;
{ IcxCustomInnerEdit }
function TcxCustomInnerMemoHelper.CallDefWndProc(AMsg: UINT; WParam: WPARAM;
LParam: LPARAM): LRESULT;
begin
Result := CallWindowProc(Edit.DefWndProc, Edit.Handle, AMsg, WParam, LParam);
end;
function TcxCustomInnerMemoHelper.GetEditValue: TcxEditValue;
begin
Result := Edit.Lines.Text;
end;
function TcxCustomInnerMemoHelper.GetOnChange: TNotifyEvent;
begin
Result := Edit.OnChange;
end;
procedure TcxCustomInnerMemoHelper.LockBounds(ALock: Boolean);
begin
with Edit do
if ALock then
Inc(FLockBoundsCount)
else
if FLockBoundsCount > 0 then
Dec(FLockBoundsCount);
end;
procedure TcxCustomInnerMemoHelper.SafelySetFocus;
var
APrevAutoSelect: Boolean;
begin
with Edit do
begin
APrevAutoSelect := AutoSelect;
AutoSelect := False;
SetFocus;
AutoSelect := APrevAutoSelect;
end;
end;
procedure TcxCustomInnerMemoHelper.SetEditValue(const Value: TcxEditValue);
begin
with Edit do
if HandleAllocated then
begin
Container.LockChangeEvents(True);
BeginInternalTextSetting;
try
if Container.IsInplace and WordWrap then
Lines.Clear;
Lines.Text := VarToStr(Value);
finally
EndInternalTextSetting;
Container.ChangeEventsCatcher.OnEditValueChangedEvent := False;
Container.LockChangeEvents(False);
end;
end
else
Text := VarToStr(Value);
end;
procedure TcxCustomInnerMemoHelper.SetParent(Value: TWinControl);
begin
Edit.Parent := Value;
end;
procedure TcxCustomInnerMemoHelper.SetOnChange(Value: TNotifyEvent);
begin
Edit.OnChange := Value;
end;
// IcxInnerTextEdit
procedure TcxCustomInnerMemoHelper.ClearSelection;
begin
Edit.ClearSelection;
end;
procedure TcxCustomInnerMemoHelper.CopyToClipboard;
begin
Edit.CopyToClipboard;
end;
function TcxCustomInnerMemoHelper.GetAlignment: TAlignment;
begin
Result := Edit.Alignment;
end;
function TcxCustomInnerMemoHelper.GetAutoSelect: Boolean;
begin
Result := Edit.AutoSelect;
end;
function TcxCustomInnerMemoHelper.GetCharCase: TEditCharCase;
begin
Result := Edit.CharCase;
end;
function TcxCustomInnerMemoHelper.GetEchoMode: TcxEditEchoMode;
begin
Result := eemNormal;
end;
function TcxCustomInnerMemoHelper.GetFirstVisibleCharIndex: Integer;
begin
Result := LoWord(SendMessage(Edit.Handle, EM_CHARFROMPOS, 0, 0));
end;
function TcxCustomInnerMemoHelper.GetHideSelection: Boolean;
begin
Result := Edit.HideSelection;
end;
function TcxCustomInnerMemoHelper.GetImeLastChar: Char;
begin
Result := #0;
end;
function TcxCustomInnerMemoHelper.GetImeMode: TImeMode;
begin
Result := Edit.ImeMode;
end;
function TcxCustomInnerMemoHelper.GetImeName: TImeName;
begin
Result := Edit.ImeName;
end;
function TcxCustomInnerMemoHelper.GetInternalUpdating: Boolean;
begin
Result := Edit.FInternalUpdating;
end;
function TcxCustomInnerMemoHelper.GetMaxLength: Integer;
begin
Result := Edit.MaxLength;
end;
function TcxCustomInnerMemoHelper.GetMultiLine: Boolean;
begin
Result := True;
end;
function TcxCustomInnerMemoHelper.GetOEMConvert: Boolean;
begin
Result := Edit.OEMConvert;
end;
function TcxCustomInnerMemoHelper.GetOnSelChange: TNotifyEvent;
begin
Result := Edit.OnSelChange;
end;
function TcxCustomInnerMemoHelper.GetPasswordChar: TCaptionChar;
begin
Result := #0;
end;
function TcxCustomInnerMemoHelper.GetReadOnly: Boolean;
begin
Result := Edit.ReadOnly;
end;
function TcxCustomInnerMemoHelper.GetSelLength: Integer;
begin
Result := Edit.SelLength;
end;
function TcxCustomInnerMemoHelper.GetSelStart: Integer;
begin
Result := Edit.SelStart;
end;
function TcxCustomInnerMemoHelper.GetSelText: string;
begin
Result := Edit.SelText;
end;
procedure TcxCustomInnerMemoHelper.SelectAll;
begin
with Edit do
if HandleAllocated then
SelectAll;
end;
procedure TcxCustomInnerMemoHelper.SetAlignment(Value: TAlignment);
begin
with Edit do
begin
Alignment := Value;
end;
end;
procedure TcxCustomInnerMemoHelper.SetAutoSelect(Value: Boolean);
begin
Edit.AutoSelect := Value;
end;
procedure TcxCustomInnerMemoHelper.SetCharCase(Value: TEditCharCase);
begin
Edit.CharCase := Value;
end;
procedure TcxCustomInnerMemoHelper.SetEchoMode(Value: TcxEditEchoMode);
begin
end;
procedure TcxCustomInnerMemoHelper.SetHideSelection(Value: Boolean);
begin
Edit.HideSelection := Value;
end;
procedure TcxCustomInnerMemoHelper.SetImeMode(Value: TImeMode);
begin
Edit.ImeMode := Value;
end;
procedure TcxCustomInnerMemoHelper.SetImeName(const Value: TImeName);
begin
Edit.ImeName := Value;
end;
procedure TcxCustomInnerMemoHelper.SetInternalUpdating(Value: Boolean);
begin
Edit.FInternalUpdating := Value;
end;
procedure TcxCustomInnerMemoHelper.SetMaxLength(Value: Integer);
begin
Edit.MaxLength := Value;
end;
procedure TcxCustomInnerMemoHelper.SetOEMConvert(Value: Boolean);
begin
Edit.OEMConvert := Value;
end;
procedure TcxCustomInnerMemoHelper.SetOnSelChange(Value: TNotifyEvent);
begin
Edit.OnSelChange := Value;
end;
procedure TcxCustomInnerMemoHelper.SetPasswordChar(Value: TCaptionChar);
begin
end;
procedure TcxCustomInnerMemoHelper.SetReadOnly(Value: Boolean);
begin
Edit.ReadOnly := Value;
end;
procedure TcxCustomInnerMemoHelper.SetSelLength(Value: Integer);
begin
Edit.SelLength := Value;
end;
procedure TcxCustomInnerMemoHelper.SetSelStart(Value: Integer);
begin
with Edit do
begin
SelStart := Value;
end;
end;
procedure TcxCustomInnerMemoHelper.SetSelText(Value: string);
begin
Edit.SelText := Value;
end;
// IcxInnerMemo
function TcxCustomInnerMemoHelper.GetCaretPos: TPoint;
begin
Result := Edit.CaretPos;
end;
function TcxCustomInnerMemoHelper.GetLines: TStrings;
begin
Result := Edit.Lines;
end;
function TcxCustomInnerMemoHelper.GetScrollBars: TScrollStyle;
begin
Result := Edit.ScrollBars;
end;
function TcxCustomInnerMemoHelper.GetWantReturns: Boolean;
begin
Result := Edit.WantReturns;
end;
function TcxCustomInnerMemoHelper.GetWantTabs: Boolean;
begin
Result := Edit.WantTabs;
end;
function TcxCustomInnerMemoHelper.GetWordWrap: Boolean;
begin
Result := Edit.WordWrap;
end;
procedure TcxCustomInnerMemoHelper.SetCaretPos(const Value: TPoint);
begin
SetMemoCaretPos(Edit, Value);
end;
procedure TcxCustomInnerMemoHelper.SetScrollBars(Value: TScrollStyle);
begin
Edit.ScrollBars := Value;
end;
procedure TcxCustomInnerMemoHelper.SetWantReturns(Value: Boolean);
begin
Edit.WantReturns := Value;
end;
procedure TcxCustomInnerMemoHelper.SetWantTabs(Value: Boolean);
begin
Edit.WantTabs := Value;
end;
procedure TcxCustomInnerMemoHelper.SetWordWrap(Value: Boolean);
begin
Edit.WordWrap := Value;
end;
{ TcxCustomInnerMemo }
constructor TcxCustomInnerMemo.Create(AOwner: TComponent);
begin
FIsCreating := True;
inherited Create(AOwner);
if not (csDesigning in ComponentState) then
Cursor := crIBeam;
ParentColor := True;
ParentFont := True;
FEchoMode := eemNormal;
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?