示例#1
0
        private void splitContainer1_Panel2_DragEnter(object sender, DragEventArgs e)
        {
            // ImageList_DragEnterにはクライアント領域における相対座標ではなく
            // タイトルバーなどの非クライアント領域を含むWindowにおける相対座標を指定する
            Point p = this.PointToClient(Cursor.Position);
            int   x = Cursor.Position.X - this.Left;
            int   y = Cursor.Position.Y - this.Top;

            // ドラッグ中は半透明イメージを表示し続けたいのでImageList_DragEnterには
            // ListBoxのHandleを渡すのでなく、FormのHandleを渡す
            Win32ImageList.ImageList_DragEnter(this.Handle, x, y);
        }
示例#2
0
        private void splitContainer1_Panel2_MouseDown(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                var image = avatarlist[0].image;
                mouseDownPoint = new Point(e.X - this.Bounds.X - image.Width / 2, e.Y - this.Bounds.Y - image.Height / 2);

                // Imageの初期化
                imageList.Images.Clear();
                imageList.ImageSize = new Size(image.Width, image.Height);

                // 半透明イメージの元画像を作成、ImageListに追加
                imageList.Images.Add(image);

                // ImageList_BeginDragにはドラッグする
                // イメージの中における相対座標を指定する
                Win32ImageList.ImageList_BeginDrag(imageList.Handle, 0, e.X, e.Y);
                int x = Cursor.Position.X + mouseDownPoint.X;
                int y = Cursor.Position.Y + mouseDownPoint.Y;
                Win32ImageList.ImageList_DragEnter(this.Handle, x, y);
            }
        }