⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 bsskingrids.pas

📁 BusinessSkinForm.v6.15汉化版支持delphi和BCB 一套支持Delphi的VCL库
💻 PAS
📖 第 1 页 / 共 5 页
字号:
  then
    with Params do
      ExStyle := ExStyle or WS_EX_TRANSPARENT
  else
    inherited;
end;

procedure TbsSkinTransparentMaskEdit.CNCTLCOLOREDIT(var Message:TWMCTLCOLOREDIT);
begin
  if FTransparent
  then
    with Message do
    begin
      SetBkMode(ChildDC, Windows.Transparent);
      SetTextColor(ChildDC, Font.Color);
      Result := GetStockObject(HOLLOW_BRUSH);
    end
  else
    inherited;
end;

procedure TbsSkinTransparentMaskEdit.WMEraseBkgnd(var Message: TWMEraseBkgnd);
begin
  if FTransparent then Invalidate else inherited;
end;

procedure TbsSkinTransparentMaskEdit.DoExit;
begin
  inherited;
  if FTransparent then Invalidate;
end;

procedure TbsSkinTransparentMaskEdit.DoEnter;
begin
  inherited;
  if FTransparent then Invalidate;
end;

procedure TbsSkinTransparentMaskEdit.WMKeyDown(var Message: TWMKeyDown);
begin
  inherited;
  if FTransparent then Invalidate;
end;

procedure TbsSkinTransparentMaskEdit.WMSetText(var Message:TWMSetText);
begin
  inherited;
  if FTransparent then Invalidate;
end;

procedure TbsSkinTransparentMaskEdit.WMMove(var Message: TMessage);
begin
  inherited;
  if FTransparent then Invalidate;
end;

procedure TbsSkinTransparentMaskEdit.WMCut(var Message: TMessage);
begin
  inherited;
  if FTransparent then Invalidate;
end;

procedure TbsSkinTransparentMaskEdit.WMPaste(var Message: TMessage);
begin
  inherited;
  if FTransparent then Invalidate;
end;

procedure TbsSkinTransparentMaskEdit.WMClear(var Message: TMessage);
begin
  inherited;
  if FTransparent then Invalidate;
end;

procedure TbsSkinTransparentMaskEdit.WMUndo(var Message: TMessage);
begin
  inherited;
  if FTransparent then Invalidate;
end;

procedure TbsSkinTransparentMaskEdit.WMLButtonDown(var Message: TWMKeyDown);
begin
  inherited;
  FDown := True;
  if FTransparent then Invalidate;
end;

procedure TbsSkinTransparentMaskEdit.WMMOUSEMOVE;
begin
  inherited;
  if FDown then Invalidate;
end;

procedure TbsSkinTransparentMaskEdit.WMLButtonUp;
begin
  inherited;
  FDown := False;
end;

procedure TbsSkinTransparentMaskEdit.Invalidate;
begin
  if FTransparent then InvalidateEdit else inherited;
end;

constructor TbsSkinInplaceEdit.Create(AOwner: TComponent);
begin
  inherited Create(AOwner);
  ParentCtl3D := False;
  Ctl3D := False;
  TabStop := False;
  BorderStyle := bsNone;
  FSysPopupMenu := nil;
end;

destructor TbsSkinInplaceEdit.Destroy;
begin
  if FSysPopupMenu <> nil then FSysPopupMenu.Free;
  inherited;
end;

procedure TbsSkinInplaceEdit.WMCONTEXTMENU;
var
  X, Y: Integer;
  P: TPoint;
begin
  if PopupMenu <> nil
  then
    inherited
  else
    begin
      CreateSysPopupMenu;
      X := Message.XPos;
      Y := Message.YPos;
      if (X < 0) or (Y < 0)
      then
        begin
          X := Width div 2;
          Y := Height div 2;
          P := Point(0, 0);
          P := ClientToScreen(P);
          X := X + P.X;
          Y := Y + P.Y;
        end;
      if FSysPopupMenu <> nil
      then
        FSysPopupMenu.Popup2(Self, X, Y)
    end;
end;

procedure TbsSkinInplaceEdit.WMAFTERDISPATCH;
begin
  if FSysPopupMenu <> nil
  then
    begin
      FSysPopupMenu.Free;
      FSysPopupMenu := nil;
    end;
end;

procedure TbsSkinInplaceEdit.DoUndo;
begin
  Undo;
end;

procedure TbsSkinInplaceEdit.DoCut;
begin
  CutToClipboard;
end;

procedure TbsSkinInplaceEdit.DoCopy;
begin
  CopyToClipboard;
end;

procedure TbsSkinInplaceEdit.DoPaste;
begin
  PasteFromClipboard;
end;

procedure TbsSkinInplaceEdit.DoDelete;
begin
  ClearSelection;
end;

procedure TbsSkinInplaceEdit.DoSelectAll;
begin
  SelectAll;
end;

procedure TbsSkinInplaceEdit.CreateSysPopupMenu;

function IsSelected: Boolean;
var
  i, j: Integer;
begin
  GetSel(i, j);
  Result := (i < j);
end;

function IsFullSelected: Boolean;
var
  i, j: Integer;
begin
  GetSel(i, j);
  Result := (i = 0) and (j = Length(Text));
end;

var
  Item: TMenuItem;
begin
  if FSysPopupMenu <> nil then FSysPopupMenu.Free;

  FSysPopupMenu := TbsSkinPopupMenu.Create(Self);
  FSysPopupMenu.ComponentForm := TForm(GetParentForm(Self));

  Item := TMenuItem.Create(FSysPopupMenu);
  with Item do
  begin
    if (FGrid.SkinData <> nil) and (FGrid.SkinData.ResourceStrData <> nil)
    then
      Caption := FGrid.SkinData.ResourceStrData.GetResStr('EDIT_UNDO')
    else
      Caption := BS_Edit_Undo;
    OnClick := DoUndo;
    Enabled := Self.CanUndo;
  end;
  FSysPopupMenu.Items.Add(Item);

  Item := TMenuItem.Create(FSysPopupMenu);
  Item.Caption := '-';
  FSysPopupMenu.Items.Add(Item);

  Item := TMenuItem.Create(FSysPopupMenu);
  with Item do
  begin
    if (FGrid.SkinData <> nil) and (FGrid.SkinData.ResourceStrData <> nil)
    then
      Caption := FGrid.SkinData.ResourceStrData.GetResStr('EDIT_CUT')
    else
      Caption := BS_Edit_Cut;
    Enabled := IsSelected and not Self.ReadOnly;
    OnClick := DoCut;
  end;
  FSysPopupMenu.Items.Add(Item);

  Item := TMenuItem.Create(FSysPopupMenu);
  with Item do
  begin
    if (FGrid.SkinData <> nil) and (FGrid.SkinData.ResourceStrData <> nil)
    then
      Caption := FGrid.SkinData.ResourceStrData.GetResStr('EDIT_COPY')
    else
      Caption := BS_Edit_Copy;
    Enabled := IsSelected;
    OnClick := DoCopy;
  end;
  FSysPopupMenu.Items.Add(Item);

  Item := TMenuItem.Create(FSysPopupMenu);
  with Item do
  begin
    if (FGrid.SkinData <> nil) and (FGrid.SkinData.ResourceStrData <> nil)
    then
      Caption := FGrid.SkinData.ResourceStrData.GetResStr('EDIT_PASTE')
    else
      Caption := BS_Edit_Paste;
    Enabled := (ClipBoard.AsText <> '') and not ReadOnly;
    OnClick := DoPaste;
  end;
  FSysPopupMenu.Items.Add(Item);

  Item := TMenuItem.Create(FSysPopupMenu);
  with Item do
  begin
    if (FGrid.SkinData <> nil) and (FGrid.SkinData.ResourceStrData <> nil)
    then
      Caption := FGrid.SkinData.ResourceStrData.GetResStr('EDIT_DELETE')
    else
      Caption := BS_Edit_Delete;
    Enabled := IsSelected and not Self.ReadOnly;
    OnClick := DoDelete;
  end;
  FSysPopupMenu.Items.Add(Item);

  Item := TMenuItem.Create(FSysPopupMenu);
  Item.Caption := '-';
  FSysPopupMenu.Items.Add(Item);

  Item := TMenuItem.Create(FSysPopupMenu);
  with Item do
  begin
    if (FGrid.SkinData <> nil) and (FGrid.SkinData.ResourceStrData <> nil)
    then
      Caption := FGrid.SkinData.ResourceStrData.GetResStr('EDIT_SELECTALL')
    else
      Caption := BS_Edit_SelectAll;
    Enabled := not IsFullSelected;
    OnClick := DoSelectAll;
  end;
  FSysPopupMenu.Items.Add(Item);
end;

procedure TbsSkinInplaceEdit.WMEraseBkgnd(var Message: TWMEraseBkgnd);
begin
  if not Transparent then inherited;
end;

procedure TbsSkinInplaceEdit.CreateParams(var Params: TCreateParams);
begin
  inherited CreateParams(Params);
  Params.Style := Params.Style or ES_MULTILINE;
end;

procedure TbsSkinInplaceEdit.SetGrid(Value: TbsSkinCustomGrid);
begin
  FGrid := Value;
end;

procedure TbsSkinInplaceEdit.CMShowingChanged(var Message: TMessage);
begin
end;

procedure TbsSkinInplaceEdit.WMGetDlgCode(var Message: TWMGetDlgCode);
begin
  inherited;
  if goTabs in Grid.Options then
    Message.Result := Message.Result or DLGC_WANTTAB;
end;

procedure TbsSkinInplaceEdit.WMPaste(var Message);
begin
  if not EditCanModify then Exit;
  inherited
end;

procedure TbsSkinInplaceEdit.WMClear(var Message);
begin
  if not EditCanModify then Exit;
  inherited;
end;

procedure TbsSkinInplaceEdit.WMCut(var Message);
begin
  if not EditCanModify then Exit;
  inherited;
end;

procedure TbsSkinInplaceEdit.DblClick;
begin
  Grid.DblClick;
end;

function TbsSkinInplaceEdit.EditCanModify: Boolean;
begin
  Result := Grid.CanEditModify;
end;

procedure TbsSkinInplaceEdit.KeyDown(var Key: Word; Shift: TShiftState);

  procedure SendToParent;
  begin
    Grid.KeyDown(Key, Shift);
    Key := 0;
  end;

  procedure ParentEvent;
  var
    GridKeyDown: TKeyEvent;
  begin
    GridKeyDown := Grid.OnKeyDown;
    if Assigned(GridKeyDown) then GridKeyDown(Grid, Key, Shift);
  end;

  function ForwardMovement: Boolean;
  begin
    Result := goAlwaysShowEditor in Grid.Options;
  end;

  function Ctrl: Boolean;
  begin
    Result := ssCtrl in Shift;
  end;

  function Selection: TSelection;
  begin
    SendMessage(Handle, EM_GETSEL, Longint(@Result.StartPos), Longint(@Result.EndPos));
  end;

  function RightSide: Boolean;
  begin
    with Selection do
      Result := ((StartPos = 0) or (EndPos = StartPos)) and
        (EndPos = GetTextLen);
   end;

  function LeftSide: Boolean;
  begin
    with Selection do
      Result := (StartPos = 0) and ((EndPos = 0) or (EndPos = GetTextLen));
  end;

begin
  case Key of
    VK_UP, VK_DOWN, VK_PRIOR, VK_NEXT, VK_ESCAPE: SendToParent;
    VK_INSERT:
      if Shift = [] then SendToParent
      else if (Shift = [ssShift]) and not Grid.CanEditModify then Key := 0;
    VK_LEFT: if ForwardMovement and (Ctrl or LeftSide) then SendToParent;
    VK_RIGHT: if ForwardMovement and (Ctrl or RightSide) then SendToParent;
    VK_HOME: if ForwardMovement and (Ctrl or LeftSide) then SendToParent;
    VK_END: if ForwardMovement and (Ctrl or RightSide) then SendToParent;
    VK_F2:
      begin
        ParentEvent;
        if Key = VK_F2 then
        begin
          Deselect;
          Exit;
        end;
      end;
    VK_TAB: if not (ssAlt in Shift) then SendToParent;
  end;
  if (Key = VK_DELETE) and not Grid.CanEditModify then Key := 0;
  if Key <> 0 then

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -