可以这样
 if 组件1.setfocus then 
    begin
      .....
    end 
  else if 组件2.Setfocus then
    begin
      .....
    end