请教KeyPreview的原理!【KeyPreview】问题了,问题解答后把把分加满~~~~~
KeyPreview本是TCustomForm公开的属性:property KeyPreview: Boolean read FKeyPreview write FKeyPreview stored IsForm default False;
且只是设置FKeyPreview而已。而TForm只是公开了这个属性而已,且在Forms单元,没找到与KeyPreview相关的代码!那么VCl如何实现的Form的KeyPreview的?
KeyPreview本是TCustomForm公开的属性:property KeyPreview: Boolean read FKeyPreview write FKeyPreview stored IsForm default False;
且只是设置FKeyPreview而已。而TForm只是公开了这个属性而已,且在Forms单元,没找到与KeyPreview相关的代码!那么VCl如何实现的Form的KeyPreview的?
解决方案 »
- 怎样隐藏主菜单中关于MDIChild最大/最小/关闭/还原等按钮
- 一个关于DBCHART的问题请教
- ~~~不可思议,怎么会是这样子啊~~~? 封装时重新改变了组件的某个属性,已经放到Form上的该组件的实例的相应属性却不会跟着改变?
- 窗体间ADOQuery调用问题?
- 强烈支持MengGirl做CSDN管理员,特此放分!
- 不知是不是Delphi问题?
- 关于在delphi中用嵌入汇编取出cpu序列号的问题
- 我想写一个局域网内的即时发通知的程序,该怎么做?
- 编程中如何释放串口
- 在DBGrid中显示记录,如何使用Enter键,使光标从一条记录的上列移动下一列。
- 哪位大侠用过devexpress的控件?(送高分,在线等待)
- ODAC控件没有类似ADO的SORT方法吗?
TForm1.FormKeyPress($CD17BC,'d')---1
TWinControl.KeyPress('d')---2
TWinControl.DoKeyPress((258, 100, 0, 2097153, 0))---3
TWinControl.DoKeyPress((258, 100, 0, 2097153, 0))---4
TWinControl.WMChar((258, 100, 0, 2097153, 0))---5
TControl.WndProc((258, 100, 2097153, 0, 100, 0, 1, 32, 0, 0))---6
TWinControl.WndProc((258, 100, 2097153, 0, 100, 0, 1, 32, 0, 0))---7
TWinControl.MainWndProc((258, 100, 2097153, 0, 100, 0, 1, 32, 0, 0))---8
StdWndProc(722470,258,100,2097153)---9
TApplication.HandleMessage---10
TApplication.Run---11
Project1---12
判断,是在第6行的TControl.WndProc中,由Dispatch(Message)语句触发了第7行的TWinControl.WMChar
我用我的小马甲问的问题,居然编程这个号问的了~
var
ShiftState: TShiftState;
Form: TCustomForm;
begin
Result := True;
Form := GetParentForm(Self);
if (Form <> nil) and (Form <> Self) and Form.KeyPreview and
TWinControl(Form).DoKeyDown(Message) then Exit;
with Message do
begin
ShiftState := KeyDataToShiftState(KeyData);
if not (csNoStdEvents in ControlStyle) then
begin
KeyDown(CharCode, ShiftState);
if CharCode = 0 then Exit;
end;
end;
Result := False;
end;
protected internal virtual bool ProcessKeyMessage(ref Message m)
{
if ((this.parent != null) && this.parent.ProcessKeyPreview(ref m))
{
return true;
}
return this.ProcessKeyEventArgs(ref m);
}
我用我的小马甲问的问题,居然编程这个号问的了~>呵呵,可能要关掉浏览器重新登陆,我用散分马甲的时候也中过一次招了。