我想在TMemo控件加入一个功能,
功能描述:是当按'Ctrl+A'时,则选中全部内容。但我不想另外加一个控件。
希望直接修改delphi基本控件的源码。
(沿用Standra面板里的那个控件)问:
1,能否修改delphi的基本控件?
2,要实现‘功能描述’应该怎个操作?
功能描述:是当按'Ctrl+A'时,则选中全部内容。但我不想另外加一个控件。
希望直接修改delphi基本控件的源码。
(沿用Standra面板里的那个控件)问:
1,能否修改delphi的基本控件?
2,要实现‘功能描述’应该怎个操作?
解决方案 »
- 关于Indy10的一个问题,在网络不通畅的情况下似乎没有超时返回,已经设置了ConnectTimeout 、ReadTimeout、TransferTimeout属性
- strtoint转换文本框内数值,如何处理逗号
- 如何判断一个字符串从最右边开始数第一个/出现的位置?
- pagecontrol的應用:如何實現從tabsheet1跳到tabsheet2?
- 使用serversocket怎么总是错误10053?一收数据就错误?急。谢谢
- 怎么可以得到在DBGrid中选中的多行数据!
- 如何得到SQL中所有的数据库名 online!
- 简单送分问题,大家快来看看啊~~~~~
- Code signing问题
- 一个工作站的计算机名是否在NT网中必须唯一。
- 哪位高手知道?!!!
- 怎么没法使用窗体的控件(比如TestFrom.label1)?
TMyMemo = class(TMemo)
private
published
//实现你的功能
end; TForm1 = class(TForm)
procedure FormCreate(Sender: TObject);
private
memo1: TMyMemo;
public
{ Public declarations }
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
memo1 := TMyMemo.Create(self);
Memo1.parent := self;
Memo1.top := .....
end;
private
procedure OnKeyPress(var Msg: TWMKEYDOWN);message WM_KEYDOWN;
end;procedure TMyMemo.OnKeyPress(var Msg: TWMKEYDOWN);
var
str: String;
begin
if (Msg.CharCode=65) and (Msg.KeyData=1966081) then
begin
Msg.Result:=1;
SelectAll;
end
end;
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;type
TMyMemo=Class(TMemo)
private
procedure OnKeyPress(var Msg: TWMKEYDOWN);message WM_KEYDOWN;
end; TForm1 = class(TForm)
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
FMemo: TMyMemo;
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}procedure TForm1.FormCreate(Sender: TObject);
begin
FMemo:=TMyMemo.Create(self);
FMemo.Parent:=Self; FMemo.Left:=20;
FMemo.Top:=20;
FMemo.Width:=Width -40;
FMemo.Height:=Height-70;
FMemo.ScrollBars:=ssBoth;
end;{ TMyMemo }procedure TMyMemo.OnKeyPress(var Msg: TWMKEYDOWN);
var
str: String;
begin
if (Msg.CharCode=65) and (Msg.KeyData=1966081) then
begin
Msg.Result:=1;
SelectAll;
end
end;end.
在memo的keydown或keyup事件写:
if (ssctrl in shift) and(key in [65,97]) then memo1.SelectAll;
就ok了
如果不行在form的keydown或keyup事件也加上这句话
you can point new on toolbar then point new commponent.
then you can create your tselectallmemo control.
other like up aliezeng77(钝刀)
begin
if (GetKeyState(VK_CONTROL)<0) and (Msg.CharCode=65) then
begin
SelectAll;
Msg.Result:=0;
end;
end;end.
procedure TCustomMemo.KeyPress(var Key: Char);
原代码如下:
procedure TCustomMemo.KeyPress(var Key: Char);
begin
inherited KeyPress(Key);
if (Key = Char(VK_RETURN)) and not FWantReturns then Key := #0;
end;
再加入一行,变成:
procedure TCustomMemo.KeyPress(var Key: Char);
begin
inherited KeyPress(Key);
if (Key = Char(VK_RETURN)) and not FWantReturns then Key := #0;
if (Key = Char(1)) then SelectAll;
end;
再想办法把它重新安装到组件面板...
但请大家看详细一点我的描述。
与我所要的结果所类似就是 Jexhat(真有你的) 所说的那种。to Jexhat(真有你的)
你说到: "... 再想办法把它重新安装到组件面板..."1,怎个办法把它重新安装到组件面板?
2,StdCtrls是那个包的?
你可以扩展它还为什么要修改它呢
或额外的加多一个面板图标。
(StdCtrls.pas里没有procedure Register;)
我没有做过bpl包, 不会啊.