继承关系
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 很有用啊