オノデラの研究日記 in わんくま

思いついたネタを気ままに書いていくブログ

ホーム 連絡をする 同期する ( RSS 2.0 ) Login
投稿数  209  : 記事  5  : コメント  5961  : トラックバック  40

ニュース

プロフィール

  • ●おのでら
    宮城県在住
    主に業務向けソフトを製作

Twitter

ニュース

主なリンク

XNA 関連リンク

アイテム

ゲーマーカード

その他

記事カテゴリ

書庫

日記カテゴリ

http://blogs.wankuma.com/rti/archive/2007/03/28/69289.aspx
http://blogs.wankuma.com/rti/archive/2007/01/10/55358.aspx
http://blogs.wankuma.com/shannon/archive/2007/01/11/55582.aspx

 以前わんくまでもスプラッシュウインドウが話題になっていたけど、解決したのか解決していないのか分からないうちに終わってしまった(?)ようなので、自分でもちょっと考えてみました。

 ApplicationContext を使って上から時系列的に書いただけなんですけどどうでしょうか?(コード直打ちなのでミスがあるかも(^^))

MyApplicationContext.cs

using System;
using System.Collections.Generic;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace YO
{
    class MyApplicationContext<MyForm> : ApplicationContext
        where MyForm : Form, new()
    {
        private SplashWindow _splash = null;
        private MyForm _myForm = null;


        /// <summary>
        /// コンストラクタ
        /// </summary>
        public MyApplicationContext() : base()
        {
            try
            {
                this._splash = new SplashWindow();
                this.MainForm = this._splash;
                this._splash.Shown += new EventHandler(splash_Shown);
            }
            catch (Exception)
            {
                // フォームの破棄
                if (this._splash != null)
                {
                    this._splash.Dispose();
                }
                base.ExitThread();
            }
        }

        /// <summary>
        /// スプラッシュが表示された直後
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void splash_Shown(object sender, EventArgs e)
        {
            try
            {
                this._myForm = new MyForm();
                this._myForm.Shown += new EventHandler(myForm_Shown);
                this._myForm.FormClosed += new FormClosedEventHandler(myForm_FormClosed);

                this._myForm.Show();
            }
            catch (Exception)
            {
                if (this._splash != null)
                {
                    this._splash.Close();
                }
            }
        }

        /// <summary>
        /// メインフォームが表示された後
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void myForm_Shown(object sender, EventArgs e)
        {
            if (this._splash != null)
            {
                this._splash.Hide();
            }
        }

        /// <summary>
        /// メインフォームが閉じられた後
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void myForm_FormClosed(object sender, FormClosedEventArgs e)
        {
            if (this._splash != null)
            {
                this._splash.Close();
            }
        }
    }
}

program.cs

//== 一部省略 ==//
[STAThread]
static void Main()
{
    //== 一部省略 ==//
    MyApplicationContext<OriginalForm> appContext = new MyApplicationContext<OriginalForm>();
    Application.Run(appContext);
}
//== 一部省略 ==//

 本来 Splash はメインのフォームが表示された後に破棄してしまいたいんですが ApplicationContext の MainForm にセットしてしまっているので仕方なく Hide してしまっています。これさえ何とかなればなぁ~…。

投稿日時 : 2007年4月15日 13:26

コメント

# re: スプラッシュウインドウ 2007/04/15 14:05 オノデラ
再編集するたびに”<>”のタグが消える…。orz
しかもさっきまで”</FORM>”のタグが自動生成されて Submit できなかったorz

Post Feedback

タイトル
名前
Url:
コメント