Win32 SDK的帮助上这样说:
The GetFocus function retrieves the handle of the window that has the keyboard focus, if the window is associated with the calling thread's message queue. 但在在下面的程序中:
在窗体上放一个Edit组件,
procedure TForm1.Button2Click(Sender: TObject);
begin
showMessage(IntToStr(Edit1.Handle));
end;procedure TForm1.Button2Click(Sender: TObject);
begin
showMessage(IntToStr(self.Handle));
end;当光标移到Edit中时点按钮执行下面的代码:
procedure TForm1.Button1Click(Sender: TObject);
begin
showMessage(IntToStr(GetFocus));
end;
返回的值既非光标所在窗体的句柄,也不是控件Edit1的窗体,GetFocus返回的究竟是什么的句柄?