我想在RichEdit控件中使用ctrl+enter快捷键,但当按下组合键ctrl+enter时,
回车键起作用了,每按一次组合键,就会插入一个换行.按组合键的时候,也不会
出发OnKeyPress事件,不能通过key:=#0来屏蔽回车键.要怎么做才能实现在按
组合键ctrl+enter时,richedit不接受enter键产生的换行?procedure TForm1.RichEdit1KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin if (key=vk_return) and (ssCtrl in shift) then
begin
showmessage('KeyDown');
end;end;procedure TForm1.RichEdit1KeyPress(Sender: TObject; var Key: Char);
begin
if key=#13 then
begin
showmessage('KeyPress');
end;
end;
回车键起作用了,每按一次组合键,就会插入一个换行.按组合键的时候,也不会
出发OnKeyPress事件,不能通过key:=#0来屏蔽回车键.要怎么做才能实现在按
组合键ctrl+enter时,richedit不接受enter键产生的换行?procedure TForm1.RichEdit1KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin if (key=vk_return) and (ssCtrl in shift) then
begin
showmessage('KeyDown');
end;end;procedure TForm1.RichEdit1KeyPress(Sender: TObject; var Key: Char);
begin
if key=#13 then
begin
showmessage('KeyPress');
end;
end;
解决方案 »
- 怎样让mdi子窗体在mdi主窗体的panel控件上显示
- 关于ACCESS字段的长度问题.
- 我用adoquery读数据, 由于数据多,读的时间长,所以想用TThread来做,请问如何实现?
- 请大家帮帮忙,看看这些备份代码的问题…
- 访问Access数据库问题
- 为什么我在IntraWeb下定义的过程 不能重复调用?有源码下载,您帮我看看?谢谢
- 救命!Access2000SQL语句问题?
- query查询sqlserver2000时参数传递的奇怪问题。
- 各位高手,一个获取Dbgrid行列的问题!!
- 如何在delphi中实现动态item的listbox,随数据库的内容变化。
- 关于delphi取时间段的问题
- idhttp 提交asp.net 的问题 急在线等
unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ComCtrls;type
TForm1 = class(TForm)
RichEdit1: TRichEdit;
Button1: TButton;
procedure RichEdit1KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure RichEdit1KeyPress(Sender: TObject; var Key: Char);
procedure hotykey(var msg:TMessage); message WM_HOTKEY;
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;
HotKey:Integer;implementation{$R *.dfm}procedure TForm1.RichEdit1KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin if (key=vk_return) and (ssCtrl in shift) then
begin
showmessage('KeyDown');
end;end;procedure TForm1.RichEdit1KeyPress(Sender: TObject; var Key: Char);
begin
if key=#13 then
begin
//showmessage('KeyPress');
end;
end;procedure TForm1.hotykey(var msg:TMessage);
begin
if (msg.LParamLo=MOD_CONTROL) and (msg.LParamHi=13) then
begin
ShowMessage('你按了ctrl+enter');
end;
end;procedure TForm1.FormCreate(Sender: TObject);
begin
HotKey:=GlobalAddAtom('HotKey');
RegisterHotKey(handle,HotKey,mod_control,13); end;procedure TForm1.FormDestroy(Sender: TObject);
begin
UnRegisterHotKey(handle,HotKey);
end;end.
procedure TForm1.RichEdit1KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if (key=vk_return) and (ssCtrl in shift) then
begin
self.RichEdit1.ReadOnly:=true;
showmessage(self.RichEdit1.Text);
end;
self.RichEdit1.ReadOnly:=false;
end;