前田稔(Maeda Minoru)の超初心者のプログラム入門
using System.Threading; |
static public Thread threads; // スレッドの領域 static public String TimeStr; // スレッドで時刻を設定 public static void Main() { try { MyForm.bmp= new Bitmap("c:\\data\\test\\girl.gif"); } catch { MessageBox.Show("イメージが取得できません", "Error"); return; } threads = new Thread(new ThreadStart(NowTime)); threads.Start(); MyForm mf = new MyForm(); Application.Run(mf); threads.Abort(); } |
public static void NowTime() { while(true) { TimeStr = DateTime.Now.ToString(); Thread.Sleep(1000); } } } |
protected override void OnPaint(PaintEventArgs e) { base.OnPaint(e); Graphics g = e.Graphics; if (SP_NO == -1) { SP_NO = 0; g.Clear(Color.LightGray); } g.DrawImage(bmp,new Rectangle(60,30,128,216),new Rectangle(SP_NO*128,0,128,216),GraphicsUnit.Pixel); textBox1.Text = anime.TimeStr; } |
超初心者の方のために全ソースコードを掲載します。 (^_^;)
全ソースコード