网上到处都有
type
TMyComponent = class (TWinControl)
...
protected
procedure CMWantSpecialKey(var Message: TCMWantSpecialKey); message CM_WANTSPECIALKEY;
...
end;procedure TMyComponent.CMWantSpecialKey(var Message: TCMWantSpecialKey); begin
inherited;
// 我们只想处理向左方向键,其它的特殊键都给 Windows 处理
if Message.CharCode = VK_LEFT then
Message.Result := 1;
end;这种做法,可是type下面都有个TForm1 = class(TForm),这个TMyComponent = class (TWinControl)
该写在哪里呢?写在TForm1 = class(TForm)的下面会出错。
type
TMyComponent = class (TWinControl)
...
protected
procedure CMWantSpecialKey(var Message: TCMWantSpecialKey); message CM_WANTSPECIALKEY;
...
end;procedure TMyComponent.CMWantSpecialKey(var Message: TCMWantSpecialKey); begin
inherited;
// 我们只想处理向左方向键,其它的特殊键都给 Windows 处理
if Message.CharCode = VK_LEFT then
Message.Result := 1;
end;这种做法,可是type下面都有个TForm1 = class(TForm),这个TMyComponent = class (TWinControl)
该写在哪里呢?写在TForm1 = class(TForm)的下面会出错。
解决方案 »
- dbExpress的TSQLQuery.CommandText不能用临时表,如:#tb1
- 散分,猪头、裤头,进来接分。。。。
- 我有两个Frame在点按钮1,或2时动态的创建在Panel中,请问我怎样动态的Free呢。。在线等待
- 侠盗飞车得到坦克的秘籍是什么?
- 一个简单的问题,D7中,打印机的打印尺寸怎样和屏幕尺寸(像素)换算?
- 怪了,关于MainMenu
- 求教: 帮忙分析一下这个函数(DELPHI菜鸟)
- 处学DELPHI:招聘~~~~老师三位~~
- 有没有可以滚动显示的label控件?
- WebBrowser可以响应flash回车键的问题!
- 各们大侠:rave report 报表如何导出到EXCEL表中?在此谢过了!!
- Qreport 的打印记录只显示了一条, 怎么调整?
TForm1 = class(TForm)
Button1: TButton;
private
{ Private declarations }
public
{ Public declarations }
end;type
TMyComponent = class (TWinControl)
protected
procedure CMWantSpecialKey(var Message: TCMWantSpecialKey); message CM_WANTSPECIALKEY;
end;var
Form1: TForm1;implementation
procedure TMyComponent.CMWantSpecialKey(var Message: TCMWantSpecialKey); begin
inherited;
// 我们只想处理向左方向键,其它的特殊键都给 Windows 处理
if Message.CharCode = VK_LEFT then
Message.Result := 1;
end;
例如拦截Memo控件的方向左键:procedure TForm1.ApplicationEvents1Message(var Msg: tagMSG;
var Handled: Boolean);
begin
if (Msg.hwnd=Memo1.Handle)and(Msg.message=WM_KEYDOWN)and(Msg.wParam=VK_LEFT)
then Handled:=True;
end;