无心漫漫 发表于 2014-12-6 18:41:31

devexpress程序只允许一个实例,默认汉化DLL,设置默认主题等

本帖最后由 无心漫漫 于 2014-12-6 18:51 编辑

我就直接上代码了

--------------------------1,程序只允许一个实例,设置程序默认皮肤等------------------------------------------------------------
    static class Program
    {
      public static System.Threading.Mutex mutex;
      /// <summary>
      /// 应用程序的主入口点
      /// </summary>
      
      static void Main()
      {
            bool noRun = false;
            mutex = new System.Threading.Mutex(true, "ThisHTShouldOnlyRunOne", out noRun);
         if (noRun)
            {
                mutex.ReleaseMutex();
                System.Threading.Thread.CurrentThread.CurrentUICulture =
                  new System.Globalization.CultureInfo("zh-Hans");
                System.Threading.Thread.CurrentThread.CurrentCulture =
                  new System.Globalization.CultureInfo("zh-Hans");
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);

                DevExpress.Skins.SkinManager.EnableFormSkins();
                DevExpress.UserSkins.BonusSkins.Register();
                UserLookAndFeel.Default.SetSkinStyle("DevExpress Style");
                Application.Run(new LoginXtraForm());
            }
            else
            {
                XtraMessageBox.Show("程序已经启动!");
                Application.Exit();
            }
      }
    }
---------------------2,显示启动动画窗体----------------------------------------
如何显示启动动画窗体?以下是代码

//在窗体构造函数中
DevExpress.XtraSplashScreen.SplashScreenManager.ShowForm(typeof(SplashScreen1));//显示启动动画窗体,SplashScreen1为新添加的启动动画窗体
InitializeComponent();
System.Threading.Thread.Sleep(3000);//延时3秒看一下效果
//在窗体Form_Load函数中
DevExpress.XtraSplashScreen.SplashScreenManager.CloseForm();//关闭启动动画窗体

----------------------3,当查询数据等时,显示等待数据正在查询中窗体-----------------------------------
//在点击查询事件开始时
DevExpress.XtraSplashScreen.SplashScreenManager.ShowForm(typeof(WaitForm1));//显示等待窗体,WaitForm1为新添加的等待窗体
//在查询事件结束后
DevExpress.XtraSplashScreen.SplashScreenManager.CloseForm();

thanhpham 发表于 2014-12-7 08:21:09

Thanksssssssssss...

阿力 发表于 2014-12-7 08:59:25

写的还是很不错的,学习了..
页: [1]
查看完整版本: devexpress程序只允许一个实例,默认汉化DLL,设置默认主题等