我在打开***.showmodal后,我想传个变理给子窗口,请问有什么办法解决呢?

解决方案 »

  1.   

    你可以在子窗口的public 中声明一个变量,然后把这个变量在窗体创建以后进行赋值就可以了。
      

  2.   

    这个方法我知道,
    我的意思想问一下在Delphi中有没有一个函数就能搞定的,因为那样的话会不会关系到资源释放的问题呢?我们在pb中可以用这个函数openwithparm(formsname,var)
      

  3.   

    也可以发送WM_COPYDATA这个消息给子窗体.然后子窗体接收这个消息。
      

  4.   

    可定义全局方法将showmodal包起来,如:procedure doShowModalChild(var value : String)
    begin
      Application.CreateForm(Tchdfrm,chdfrm);
      chdfrm.showmodal;
      chdfrm.free;
    end
      

  5.   

    用全局变量不好。
    可以这样做:
    在子窗体的PUBLIC段中建一个函数,比方说:
    public
      function Execute(AParam: Integer): Booleanfunction TForm2.Execute(AParam: Integer): Boolean;
    begin
      ...  //处理参数
      Result := (ShowModal=mrOK);
    end;在主窗口中的代码:with TForm2.Create(Self) do
    try
      Execute(100);       //给它一个参数
    finally
      Free;
    end;