delphi 如何使得编辑框内容不能被选中或全选
如题,可读可写,但是不能选中里面的字符进行复制。我要做的不是禁用编辑框的右键菜单,只是想要不能选中里面的字符。...
如题,可读可写,但是不能选中里面的字符进行复制。我要做的不是禁用编辑框的右键菜单,只是想要不能选中里面的字符。
展开
2个回答
2013-06-02
展开全部
是可以的 unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls; type
TArcanMemo=class(TMemo)
procedure WndProc(var Message : TMessage); override;
procedure WMRButtonUp(var Message: TWMRButtonUp);message WM_RBUTTONUP;
procedure WMCopy(var Message: TWMCopy);message WM_Copy;
procedure WMPaste(var Message: TWMPaste);message WM_Paste;
end; type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end; var
Form1: TForm1;implementation{$R *.dfm}
procedure TArcanMemo.WMCopy(var Message: TWMCopy);
begin
Message.Result := 1;
end;procedure TArcanMemo.WMPaste(var Message: TWMPaste);
begin
Message.Result := 1;
end;procedure TArcanMemo.WMRButtonUp(var Message: TWMRButtonUp);
begin
Message.Result := 1;
end;procedure TArcanMemo.WndProc(var Message: TMessage);
begin
if (message.Msg =WM_RBUTTONUP) or (message.Msg =WM_RBUTTONDOWN) then
exit;
if (message.Msg =wm_copy) or (message.Msg =wm_cut) then
exit;
if message.Msg =wm_paste then
exit;
inherited WndProc(Message);end;
procedure TForm1.Button1Click(Sender: TObject);
var memo: TArcanMemo;
begin
memo:=TArcanMemo.Create(self);
memo.Parent:=self;
memo.Left:=50;
memo.top:=50;
memo.Height:=50;
memo.Width:=50; end;end.
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls; type
TArcanMemo=class(TMemo)
procedure WndProc(var Message : TMessage); override;
procedure WMRButtonUp(var Message: TWMRButtonUp);message WM_RBUTTONUP;
procedure WMCopy(var Message: TWMCopy);message WM_Copy;
procedure WMPaste(var Message: TWMPaste);message WM_Paste;
end; type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end; var
Form1: TForm1;implementation{$R *.dfm}
procedure TArcanMemo.WMCopy(var Message: TWMCopy);
begin
Message.Result := 1;
end;procedure TArcanMemo.WMPaste(var Message: TWMPaste);
begin
Message.Result := 1;
end;procedure TArcanMemo.WMRButtonUp(var Message: TWMRButtonUp);
begin
Message.Result := 1;
end;procedure TArcanMemo.WndProc(var Message: TMessage);
begin
if (message.Msg =WM_RBUTTONUP) or (message.Msg =WM_RBUTTONDOWN) then
exit;
if (message.Msg =wm_copy) or (message.Msg =wm_cut) then
exit;
if message.Msg =wm_paste then
exit;
inherited WndProc(Message);end;
procedure TForm1.Button1Click(Sender: TObject);
var memo: TArcanMemo;
begin
memo:=TArcanMemo.Create(self);
memo.Parent:=self;
memo.Left:=50;
memo.top:=50;
memo.Height:=50;
memo.Width:=50; end;end.
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2013-06-02
展开全部
响应GetFocus()消息,SetCurSel(-1,-1).
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询