끌어서 놓을 때 PictureBox를 움직이는 방법을 만들었습니다. 나는 PictureBox를 드래그하고있어 때, 이미지는 이미지의 실제 크기를 가지고 있는데 이미지가드래그 앤 드롭 드래그 할 때 PictureBox- 이미지 크기 이동
private void pictureBox1_MouseDown(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
picBox = (PictureBox)sender;
var dragImage = (Bitmap)picBox.Image;
IntPtr icon = dragImage.GetHicon();
Cursor.Current = new Cursor(icon);
DoDragDrop(pictureBox1.Image, DragDropEffects.Copy);
DestroyIcon(icon);
}
}
protected override void OnGiveFeedback(GiveFeedbackEventArgs e)
{
e.UseDefaultCursors = false;
}
protected override void OnDragEnter(DragEventArgs e)
{
if (e.Data.GetDataPresent(typeof(Bitmap))) e.Effect = DragDropEffects.Copy;
}
protected override void OnDragDrop(DragEventArgs e)
{
picBox.Location = this.PointToClient(new Point(e.X - picBox.Width/2, e.Y - picBox.Height/2));
}
[System.Runtime.InteropServices.DllImport("user32.dll")]
extern static bool DestroyIcon(IntPtr handle);
이미지가 그림 상자에 맞게 축소되도록 하시겠습니까? –
http://www.dotnetcurry.com/ShowArticle.aspx?ID=179 – MethodMan
@glace 예, 그림 상자에 수축이 필요합니다. – Ladessa