通过asp js调用组件模式窗体showdialog,模式窗体却以非模式窗体显示

     这可能是因为在一个线程中的原因,可以在组件中重启一个线程。

  

public void BeginShowForm()
  {
   System.Threading.Thread thread1=new System.Threading.Thread(new ThreadStart(this.ShowForm));
      thread1.ApartmentState=ApartmentState.STA;
   thread1.Start();
   thread1.Join();
  }

  public void ShowForm()
  //private void PubLinkInterface_Load(object sender, System.EventArgs e)
  {
   try
   {
    /***********************Test********************************/
//    this.dll = "PU_Control.dll";
//    this.isClassName = "Genersoft.Drp.PU.Control.IM_EstQutity_Query";
//    this.processID = "fqq";
//    this.isCondition = "_CompanyID::1010::_Org::00000000000000000003::_WareHouse::00000000000000000066::_FiscalYear::2004::_FicalPeriod::12::_Module::IM";
    /*************************End*******************************/
    /***********************************************************
     如果FocusUpdate存在则在注册表里寻找dll
     否则为开发环境测试手动拷贝dll到相应的目录
     ***********************************************************/
    RegistryKey hklm = Registry.LocalMachine ;
    RegistryKey SOFTWARE = hklm.OpenSubKey ( "SOFTWARE" ) ;
    RegistryKey Genersoft = SOFTWARE.OpenSubKey ( "Genersoft" ) ;
    Genersoft=Genersoft.OpenSubKey ( "FocusUpdate" ) ;
    this.error = "取注册表信息出错!";
    if (Genersoft == null)
    {
     this.error = "开发环境构造DLL文件路径出错:";
     AppDomain MyApp=AppDomain.CurrentDomain;
     isAssemblyName = MyApp.BaseDirectory+this.dll;
     
     //开发环境中:直接由AppDomain取dll文件 ;如果文件不存在,则根据dll文件名构造模块路径
     //By Vaooya
     FileInfo vfileInfo=new FileInfo(isAssemblyName);
     if(!vfileInfo.Exists)
     {
      isAssemblyName=isAssemblyName.Substring(0,isAssemblyName.IndexOf(@"PUB_Debug\bin\Debug\"))+this.dll.Substring(0,this.dll.LastIndexOf("."))+@"\bin\"+this.dll;
     }
    }
    else
    {
     isAssemblyName = Genersoft.GetValue("StorageLocation").ToString();
     isAssemblyName = isAssemblyName +"\\"+ this.dll;

    }
    /********************************************
     加载需要的dll动态链接库
     ********************************************/
    this.error = "Assembly加载出错!";
    System.Reflection.Assembly assem = Assembly.LoadFrom(this.isAssemblyName);    
    Type ClassType = assem.GetType(this.isClassName);
    Object obj = ClassType.Assembly.CreateInstance(ClassType.FullName);
    BindingFlags bf = BindingFlags.Instance|BindingFlags.NonPublic|BindingFlags.Public|BindingFlags.FlattenHierarchy| BindingFlags.SetField ;
    PropertyInfo pi = ClassType.GetProperty("ProcessID");
    pi.SetValue(obj,processID,null);
    /********************************************
     分割传递的isCondition参数
    *********************************************/
    this.error = "解析isCondition出错!";
    Regex RegExp=new Regex("::");
    string[] isConditions = RegExp.Split(isCondition);
    Hashtable hl = new Hashtable();
    for(int i=0;i<isConditions.Length;i++)
    {
     hl.Add(isConditions[i],isConditions[i+1]);
     i++;     
    }
    /*******************************************
     构造出相应的键值对,SetValue给相应的类
     ******************************************/
    this.error = "没有对应的属性!";
    foreach(DictionaryEntry de in hl) //ht为一个Hashtable实例
    {
     string a = de.Key.ToString();//de.Key对应于key/value键值对key
     string b = de.Value.ToString();//de.Key对应于key/value键值对value
     if((a != "")&&(b != ""))
     {
      PropertyInfo pii = ClassType.GetProperty(a.ToString(),bf);
      pii.SetValue(obj,b,null);
     }
    }
//    Type[] bt = new Type[]{};
//    MethodInfo mi = ClassType.GetMethod("ShowDialog",bt);
//    mi.Invoke(obj,null);
    
    Form form1=(Form)obj;
    form1.MdiParent=this.ParentForm;
    form1.ShowDialog();
    form1.Focus();

    
    if(this.Parent!=null)
     this.Parent.Dispose();
    else
                    this.Close();
   }
   catch(Exception ex)
   {
    MessageBox.Show(error+ex.Message);
   }
  }

转载于:https://www.cnblogs.com/inspurhaitian/archive/2008/09/17/1292397.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值