こちらのページを参考に、
デスクトップマスコットを作りたいのですが、
エラーがでてうまく行きません。
下のコードは、Form1.csに書いたコードです。
(上のリンクの下の方のものです。)
using System; using System.Drawing; using System.Windows.Forms; namespace デスクトップマスコット { public partial class Form1 : Form { string path; private int mouseX; private int mouseY; public Form1() { InitializeComponent(); //背景透過 this.TransparencyKey = BackColor; //手前表示 this.TopMost = !this.TopMost; } private void Form1_Load(object sender, EventArgs e) { //パスの指定 path = @"Resources\human.png"; show(path); } //画像を表示する private void show(string path) { //フォームの境界線をなくす this.FormBorderStyle = FormBorderStyle.None; //フォームのサイズ変更 size_change(@path); //背景画像を指定する this.BackgroundImage = Image.FromFile(@path); } //ウィンドウの大きさを画像の大きさに変更 private void size_change(string path) { //元画像の縦横サイズを調べる System.Drawing.Bitmap bmpSrc = new System.Drawing.Bitmap(@path); int width = bmpSrc.Width; int height = bmpSrc.Height; //ウィンドウのサイズを変更 this.Size = new Size(width, height); } //マウスドラッグ移動処理 private void Form1_MouseDown(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Left) { this.mouseX = e.X; this.mouseY = e.Y; } } private void Form1_MouseMove(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Left) { this.Left += e.X - mouseX; this.Top += e.Y - mouseY; } } } }
これだと、エラーコードCS0103がでます。
(CS0103 現在のコンテキストに'initializeComponent'という名前は存在しません。)
どうにか解決できる方はいませんでしょうか?
(記事内にコメントしたのですが一年前の記事であるのか返信がないのでここでお聞きしています)
回答3件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2017/08/28 01:57