zoukankan      html  css  js  c++  java
  • 通过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);
       }
      }

  • 相关阅读:
    socket bind详解
    Hibernate简单的基础理论
    Web的工作机制
    部署hibernate框架项目时出现问题:The type java.lang.Object cannot be resolved. It is indirectly referenced from required .class files.
    Spring简单的小例子SpringDemo,用于初略理解什么是Spring以及JavaBean的一些概念
    Hibernate项目里配置环境时,jar包配置不当会对测试结果产生影响。
    转载——Struts2中的constant详解
    同样的WiFi,手机能连上网,电脑不能。错误代码DNS_PROBE_POSSIBLE
    eclipse外部导入Javaweb项目时,项目上出现红叉的一个可能的解决办法
    依赖注入的实现方式:设值注入和构造方法注入
  • 原文地址:https://www.cnblogs.com/inspurhaitian/p/1292397.html
Copyright © 2011-2022 走看看