再探dxRTTIInspector

继承关系

TObject  (system)

TPersistent  (Classes)

TComponent  (Classes)

TControl  (Controls)

TWinControl  (Controls)

TCustomControl  (Controls)

TCustomdxContainer  (dxCntner)

TCustomdxInspector  (dxInspct)

TCustomdxInspectorControl  (dxInspct)

TCustomdxRTTIInspector  (dxOI)

TdxRTTIInspector  (dxOI)

属性编辑器增加右键复制属性名称功能

1、D:\Program Files\Developer Express Inc\ExpressInplaceEditors\Delphi 7\Sources\dxEdStr.pas

增加了一行

  dxEditCopyPropName                 = 38957; // 'Copy PropName'

{$R dxEdStr.res} 根据这一行知道有资源文件,就是字符串

2、D:\Program Files\Developer Express Inc\ExpressInplaceEditors\Delphi 7\Sources\dxEdStr.rc

  38957, "Copy PropName"

3、控件处理WM_CONTEXTMENU消息就是右键菜单

   D:\Program Files\Developer Express Inc\ExpressInplaceEditors\Delphi 7\Sources\dxEditor.pas

    procedure WMContextMenu(var Message: TMessage); message WM_CONTEXTMENU;

procedure TdxInplaceTextEdit.WMRButtonUp(var Message: TWMRButtonUp);
var
  P: TPoint;
begin
  inherited;
//  if IsDisableDragDrop then // IRichEditOleCallback.GetContextMenu
  begin
    P := SmallPointToPoint(Message.Pos);
    Windows.ClientToScreen(Handle, P);
    PostMessage(Handle, WM_CONTEXTMENU, Handle, Integer(PointToSmallPoint(P)));
  end;
end;

4、增加右键菜单消息是WM_CONTEXTMENU ;

procedure WMRButtonUp(var Message: TWMRButtonUp); message WM_RBUTTONUP;

procedure WMContextMenu(var Message: TMessage); message WM_CONTEXTMENU;

Add(NewItem(sdxEditCopyPropName, -8));

procedure TdxInplaceTextEdit.WMRButtonUp(var Message: TWMRButtonUp);
var
  P: TPoint;
begin
  inherited;
//  if IsDisableDragDrop then // IRichEditOleCallback.GetContextMenu
  begin
    P := SmallPointToPoint(Message.Pos);
    Windows.ClientToScreen(Handle, P);
    PostMessage(Handle, WM_CONTEXTMENU, Handle, Integer(PointToSmallPoint(P)));
  end;
end;

procedure TdxInplaceTextEdit.WMContextMenu(var Message: TMessage);

procedure TdxInplaceTextEdit.WMContextMenu(var Message: TMessage);

  function NewItem(const ACaption: string; ATag: Integer): TMenuItem;
  begin
    Result := TMenuItem.Create(Self);
    with Result do
    begin
      Caption := ACaption;
      Tag := ATag;
      OnClick := EditPopupMenuClick;//右键单击事件
    end;
  end;


  procedure UpdateItems;
  var
    F: Boolean;
  begin
    with FEditPopupMenu do
    begin
      F := SelLength > 0;
      Items[0].Enabled := CanUndo;
      Items[1].Enabled := CanRedo;
      Items[3].Enabled := F and CanModify and (PasswordChar = #0);
      Items[4].Enabled := F and (PasswordChar = #0);
      Items[5].Enabled := CanPaste;
      Items[6].Enabled := F and CanModify;
      Items[8].Enabled := SelLength <> GetTextLenEx;
    end;
  end;


var
  P: TPoint;
begin
  inherited;
  if IsEditClass and (Message.Result = 0) and not HasPopup(Self) {DELPHI3} then
  begin
    P := SmallPointToPoint(TSmallPoint(Message.LParam));
    if (P.X = -1) and (P.Y = -1) then
    begin
      GetCaretPos(P);
      if P.X > ClientWidth then
        P.X := ClientWidth; 
      Windows.ClientToScreen(Handle, P);
    end
    else
      if not PtInRect(ClientRect, ScreenToClient(P)) then Exit;
    // Popup
    if FEditPopupMenu = nil then
    begin
      FEditPopupMenu := TPopupMenu.Create(Self);
      with FEditPopupMenu.Items do
      begin
        Add(NewItem(sdxEditUndoCaption, -1));
        Add(NewItem(sdxEditRedoCaption, -2));
        Add(NewItem('-', MaxInt));
        Add(NewItem(sdxEditCutCaption, -3));
        Add(NewItem(sdxEditCopyCaption, -4));
        Add(NewItem(sdxEditPasteCaption, -5));
        Add(NewItem(sdxEditDeleteCaption, -6));
        Add(NewItem('-', MaxInt));
        Add(NewItem(sdxEditSelectAllCaption, -7));
        Add(NewItem(sdxEditCopyPropName, -8));//ksr 2013.6.19
      end;
    end;
    UpdateItems;
    FEditPopupMenu.Popup(P.X, P.Y);
  end;
end;

procedure TdxInplaceTextEdit.EditPopupMenuClick(Sender: TObject);
begin
  case TMenuItem(Sender).Tag of
    -1: Undo;
    -2: Redo;
    -3: CutToClipboard;
    -4: CopyToClipboard;
    -5: PasteFromClipboard;
    -6: ClearSelection;
    -7: SelectAll;
  end;
end;

给dxRTTIInspector增加右键,可以在TdxRTTIInspector、TCustomdxRTTIInspector增加都可以弹出右键,且编辑修改属性值时不会弹出的,效果可以接受。

procedure WMRButtonUp(var Message: TWMRButtonUp); message WM_RBUTTONUP;

procedure TCustomdxRTTIInspector.WMRButtonUp(var Message: TWMRButtonUp);
begin
  ShowMessage('WMRButtonUp');
end;

TCustomdxInspectorControl这里增加右键效果如何呢?竟然也可以


FocusRowByPropertyName 很有用啊

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值