| ■No25027 (あこ さん) に返信 > はじめまして。 Visual Studio .NET 2003 でC#を勉強中です。 > 本やネットなどで調べているのですが、状況改善には至っていません。 > 初歩的な質問だとは思いますが、皆様のお力をお貸しいただけないでしょうか宜しくお願い致します。 > > > > //1 > using System.Drawing; > using System.Windows.Forms; > > public class Test : Form > { > private Image image; > > protected override void OnPaint(PaintEventArgs e) > { > base.OnPaint(e); > if(image == null) image = Image.FromFile("aiai1.jpg"); > e.Graphics.DrawImage(image, 0, 0); > > Font font1 = new Font("Arial", 80, FontStyle.Bold); > SolidBrush brush1 = new SolidBrush(Color.Black); > string text1 = "abcde"; > RectangleF rect1 = new RectangleF(120, 100, 784, 120); > e.Graphics.DrawString(text1, font1, brush1, rect1); > } > > //ココに下記のMouseDownを入れようとしてます。 > > static void Main() > { > Application.Run(new Test()); > } > } > > > > > //2 > Protected override void OnMouseDown(MouseEventArgs e) > { > base.OnMouseDown(e); > > image = Image.FromFile("aiai2.jpg"); > e.Graphics.DrawImage(image, 0, 0); > > string text2 = "fghij"; > RectangleF rect1 = new RectangleF(120, 100, 784, 120); > e.Graphics.DrawString(text2, font1, brush1, rect1); > } > > > 私が作成したソースはこのような感じなのですが、//1 だとaiai1.jpgを表示してabcdeとコメントを書いたものが表示されます。 > これに//2を書き加えて、クリック(やキー)操作で次のaiai2.jpgを表示させてfghijをコメントとして表示させたいのです。 > 次にaiai3..aiai4..aiti5..と続けていきたいのですが > Protected override void OnMouseDown(MouseEventArgs e)の中でGraphicsが使えないのです。 > もし、お時間に余裕ありましたら教えて頂けないでしょうか >
http://homepage1.nifty.com/rucio/main/main.htm 余計なことかもしれませんが、最新のvB2008は使い勝手がよくなってますよ。
|