类似Form,Button这样的组件都有Keydown事件。如果输入焦点在button上,当有键盘输入的时候,button的keydown事件会被调用,而form的KeyDown事件就不起作用了。有没有什么办法可以原封不动的把该消息再次发给form 的keydown事件?
解决方案 »
- 错误信息Access violation....
- 请问通过网络如何来发消息啊?
- 关于两个指针的连接问题请教
- 用DELPHI写ACTIVEX,放到IE浏览器中,为什么方向键和TAB键不好用了??
- 如何将Image控件中的图片一分为二存到别两个Image控件中?
- 简单问题
- 数据集的 applyupdate 是怎么样对data 和 delta 操作的?
- TMessage这个类中的字段意思?
- 注册表的读取,肯定在线,不敢离开,高手救命呀!解决立即给分!!!
- 这是一个邮件发送的问题......
- 这个报表如何做?那些memo不太好处理
- 在dephi中怎么做超级链接?不做为网页形式,而是用外部命令Explorer.exe执行
const WM_MYMESSAGE=WM_USER+1234;
处理消息函数:
procedure OnMyMessage(var message:tmessage);message WM_MYMESSAGE
begin
dispatch(xxxx//发送自定义消息
以下代码为证
function TWinControl.DoKeyDown(var Message: TWMKey): Boolean;
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;
var Handled: Boolean);
begin
if (Msg.hwnd=Button1.Handle) and (Msg.message=WM_KEYDOWN) then
Form1.Perform(Msg.message,Msg.wParam,Msg.lParam);
end;
Button1KeyDown
begin
...
Form1.KeyDown(Sender);
end;
Button1KeyDown=Form1KeyDown