问题表述:当前的窗口里面有1个Edit控件:
1、当前焦点窗口为本程序窗口时,为何不执行WM_SETFOCUS ?
2、当前焦点窗口不为本程序窗口时,为何不执行WM_KILLFOCUS ?
若没有Edit控件,这些代码都可以正常执行,原因出在什么地方,若想让这些消息都能正常执行,我应该将此代码加在何处,请高手帮忙!
TForm1 = class(TForm)
Edit1: TEdit;
private
procedure WMSetFocus(var Message: TWMSetFocus); message WM_SETFOCUS;
procedure WMKillFocus(var Message: TWMSetFocus); message WM_KILLFOCUS;
procedure WndProc(var Msg: TMessage); override;
end;
implementation
procedure TForm1.WMSetFocus(var Message: TWMSetFocus);
begin
Caption := Caption + '1';
end;procedure TForm1.WMKillFocus(var Message: TWMSetFocus);
begin
Caption := Caption + '2';
end;procedure TForm1.WndProc(var Msg: TMessage);
begin
inherited; if Msg.Msg = WM_SETFOCUS then
Caption := Caption + '3'
else if Msg.Msg = WM_KILLFOCUS then
Caption := Caption + '4';
end;
1、当前焦点窗口为本程序窗口时,为何不执行WM_SETFOCUS ?
2、当前焦点窗口不为本程序窗口时,为何不执行WM_KILLFOCUS ?
若没有Edit控件,这些代码都可以正常执行,原因出在什么地方,若想让这些消息都能正常执行,我应该将此代码加在何处,请高手帮忙!
TForm1 = class(TForm)
Edit1: TEdit;
private
procedure WMSetFocus(var Message: TWMSetFocus); message WM_SETFOCUS;
procedure WMKillFocus(var Message: TWMSetFocus); message WM_KILLFOCUS;
procedure WndProc(var Msg: TMessage); override;
end;
implementation
procedure TForm1.WMSetFocus(var Message: TWMSetFocus);
begin
Caption := Caption + '1';
end;procedure TForm1.WMKillFocus(var Message: TWMSetFocus);
begin
Caption := Caption + '2';
end;procedure TForm1.WndProc(var Msg: TMessage);
begin
inherited; if Msg.Msg = WM_SETFOCUS then
Caption := Caption + '3'
else if Msg.Msg = WM_KILLFOCUS then
Caption := Caption + '4';
end;
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货