- 71 名前:デフォルトの名無しさん mailto:sage [2010/02/05(金) 18:21:50 ]
- >>60
画像を親ピクチャーのImageではなくBackGroundImageに設定する。親ピクチャーボックスをparentPBとすると 別解その2 Point mPos = Point.Empty; Rectangle vtb = new Rectangle(0, 0, 100, 20); // 仮想テキストボックス private void parentPB_MouseDown(object sender, MouseEventArgs e) { if (!vtb.Contains(e.Location)) return; mPos = e.Location; mPos.Offset(-vtb.Location.X, -vtb.Location.Y); Point p = this.PointToScreen(parentPB.Location); p.Offset(e.Location.X - vtb.Location.X, e.Location.Y - vtb.Location.Y); Cursor.Clip = new Rectangle(p, new Size(parentPB.Width - vtb.Width, parentPB.Height - vtb.Height)); } private void parentPB_MouseMove(object sender, MouseEventArgs e) { if (mPos == Point.Empty) return; vtb.X = e.X - mPos.X; vtb.Y = e.Y - mPos.Y; parentPB.Invalidate(); } private void parentPB_MouseUp(object sender, MouseEventArgs e) { Cursor.Clip = Rectangle.Empty; mPos = Point.Empty; } private void parentPB_Paint(object sender, PaintEventArgs e) { e.Graphics.DrawRectangle(Pens.Yellow, Rectangle.Round(vtb)); e.Graphics.DrawString(textBox1.Text, textBox1.Font, new SolidBrush(textBox1.ForeColor), vtb.Location); }
|

|