-4

問題controls.add(pic)

private void blockRoadMouseMove(System.Object sender,
          System.Windows.Forms.MouseEventArgs e)
    {
        if (e.Button == MouseButtons.Left)
        {
            if (Control.ModifierKeys == Keys.Control)
            {
                int yo = this.Location.Y;
                int startx = this.Left;
                int cx = startx;
                int mo = e.X + this.Left - clickOffsetX;

                DrawingControl.SuspendDrawing(mainPic);
                mainPic.SuspendLayout();
                blockRoad pic = new blockRoad(mainPic);
                DrawingControl.SuspendDrawing(pic);

                for (int t = cx; t < mo; t += 20)
                {
                    pic.setChar(this.Image, t, yo);
                }
                mainPic.ResumeLayout();
                DrawingControl.ResumeDrawing(mainPic);
            }
        }
    }    

私はそれを使用しました

class DrawingControl
    {
        [DllImport("user32.dll")]
        public static extern int SendMessage(IntPtr hWnd, Int32 wMsg, bool wParam, Int32 lParam);

        private const int WM_SETREDRAW = 11;

        public static void SuspendDrawing(Control parent)
        {
            SendMessage(parent.Handle, WM_SETREDRAW, false, 0);
        }

        public static void ResumeDrawing(Control parent)
        {
            SendMessage(parent.Handle, WM_SETREDRAW, true, 0);
            parent.Refresh();
        }
    }

問題は、1 つの位置に多くの (写真) を追加することです。次の位置に多くの追加..次の追加...

(すべての) 1 つの位置に多くの写真を追加する すべての位置に (1 つの) 写真を追加したい

4

1 に答える 1

0

blockRoadがこの場所にない場合(追加)、追加(確認)することで問題を解決しました

for (int t = cx; t < mo; t += 20)
{
    Control c = pic.GetChildAtPoint(new Point(cx, y));

    if (c == null)
    {
        pic.setChar(this.Image, t, yo);
        pic.Controls.Add(pic);
    }
}

別の解決策がある場合は、ありがとう

于 2013-01-16T18:47:55.043 に答える