delphi中的窗体怎么取得焦点
展开全部
例如:有form1、form2 两个窗体,form1中有两个按钮,
button2是显示form2并将焦点设置于edit3。 程序如下:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
uses Unit2;
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
form1.SetFocus;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
form2.Show;
//form2.setfocus;
form2.Edit3.SetFocus;
end;
end.
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询