通過asp js調用組件模式表單showdialog,模式表單卻以非模式表單顯示

來源:互聯網
上載者:User

     這可能是因為在一個線程中的原因,可以在組件中重啟一個線程。

  

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);
   }
  }

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.