procedure wmchar(var message :tmessage);message wm_char; uses messages; procedure wmchar(var message :tmessage); begin if message.wparam=enter then message.wparam=tabkey; inherited; end;
谢谢二位的回答回答. 照抄wfhlxl()的代码并放在单元文件的适当位置后,编译通不过,说找不到wparam定义,估计您这是个大致说明.遂按照您例子中的指引,找到了过程WMChar在Controls.pas中原型定义,并写成如下的样子.虽然可以编译成功,但运行时的效果是按任何键都没反应,除非按Enter时响一下"叮"外,焦点也不会移动的. 烦请各位再帮我诊断一下. 十万分的感激!!! unit Edit1;interfaceuses SysUtils, Classes, Controls, StdCtrls,Dialogs, Graphics,Messages;type TEdit1 = class(TEdit) private { Private declarations } protected procedure WMChar(var Message: TWMChar); message WM_CHAR; { Protected declarations } public { Public declarations } published { Published declarations } end;procedure Register;implementation//--------------------- procedure Register; begin RegisterComponents('MyComponents', [TEdit1]); end;//--------------------- procedure TEdit1.WMChar(var Message: TWMChar); begin if message.CharCode=13 then begin message.CharCode:=9; inherited; end; end;end.
procedure Tmaterial1.FormKeyPress(Sender: TObject; var Key: Char); begin if Ord(Key) = VK_RETURN then Keybd_Event(VK_TAB, MapVirtualKey(VK_TAB, 0), 0, 0); end;再把form的keypreview设为true
procedure TEdit1.WMChar(var Message: TWMChar); begin if message.CharCode=13 then begin sendmessage(parent.handle,wm_keyup,9,0);// parent have two can get focus controls at least inherited; end; end
procedure TEdit1.WMChar(var Message: TWMChar); begin if message.CharCode=13 then begin sendmessage(parent.handle,wm_keydwon,9,0);// sendmessage(parent.handle,wm_keyup,9,0);// parent have two can get focus controls at least inherited; end; end
"我是说在创建基于Tedit的组建时:" 应为 "我是说在创建基于Tedit的组件时:"
uses messages;
procedure wmchar(var message :tmessage);
begin
if message.wparam=enter then
message.wparam=tabkey;
inherited;
end;
照抄wfhlxl()的代码并放在单元文件的适当位置后,编译通不过,说找不到wparam定义,估计您这是个大致说明.遂按照您例子中的指引,找到了过程WMChar在Controls.pas中原型定义,并写成如下的样子.虽然可以编译成功,但运行时的效果是按任何键都没反应,除非按Enter时响一下"叮"外,焦点也不会移动的.
烦请各位再帮我诊断一下. 十万分的感激!!!
unit Edit1;interfaceuses
SysUtils, Classes, Controls, StdCtrls,Dialogs, Graphics,Messages;type
TEdit1 = class(TEdit)
private
{ Private declarations }
protected
procedure WMChar(var Message: TWMChar); message WM_CHAR;
{ Protected declarations }
public
{ Public declarations }
published
{ Published declarations }
end;procedure Register;implementation//---------------------
procedure Register;
begin
RegisterComponents('MyComponents', [TEdit1]);
end;//---------------------
procedure TEdit1.WMChar(var Message: TWMChar);
begin
if message.CharCode=13 then
begin
message.CharCode:=9;
inherited;
end;
end;end.
begin
if Ord(Key) = VK_RETURN then Keybd_Event(VK_TAB, MapVirtualKey(VK_TAB, 0), 0, 0);
end;再把form的keypreview设为true
begin
if message.CharCode=13 then
begin
sendmessage(parent.handle,wm_keyup,9,0);// parent have two can get focus controls at least
inherited;
end;
end
begin
if message.CharCode=13 then
begin
sendmessage(parent.handle,wm_keydwon,9,0);//
sendmessage(parent.handle,wm_keyup,9,0);// parent have two can get focus controls at least
inherited;
end;
end