每个窗口增加一个Public属性,叫 UID,表示对方的ID号码,假设聊天窗口的类型为TFormXfunction ExistForm(UID:Integer):Boolean;var i:Integer;begin result:=false; for I:=0 to screen.FormCount-1 do begin if not (screen.forms is TformX) then continue; IF TFormX(SCreen.Forms).UID= UID Then begin result:=True; Break; end; end;end;个别地方可能存在语法错误,思路你应该可以看懂。