拖动窗体MOUSEUP怎么写,用什么方法?

解决方案 »

  1.   

    拖动窗体MOUSEUP怎么写
    -------
    不明白你要的是什么?拖动窗体,是移动窗体,还是高速大小,还是都是.
    为什么要写MouseUp事件,而不用MouseMove或MouseDown事件呢?
      

  2.   

    MouseMove,MouseDown已经实现了,就是MOUSEUP没有实现?
      

  3.   

    //参考如下代码:
    //客户区拖动窗体        [DllImport("User32.DLL")]
            public static extern int SendMessage(IntPtr hWnd, uint Msg, int wParam, int iParam);
            [DllImport("User32.DLL")]
            public static extern bool ReleaseCapture();
            public const uint WM_SYSCOMMAND = 0x0112;
            public const int SC_MOVE = 61456;
            public const int HTCAPTION = 2;        private void Form1_MouseDown(object sender, MouseEventArgs e)
            {
                ReleaseCapture();
                SendMessage(Handle, WM_SYSCOMMAND, SC_MOVE | HTCAPTION, 0);
            }
      

  4.   

    定义了一个BOOL类型的变量stopMove,可就是不记得那句话该怎么写了
      

  5.   

    把如下代码粘入窗口试试:
    internal static int WM_NCHITTEST = 0x84; //移动鼠标,按住或释放鼠标时发生的系统消息
    internal static IntPtr HTCLIENT = (IntPtr)0x1;//工作区
    internal static IntPtr HTCAPTION = (IntPtr)0x2; //标题栏
    protected override void WndProc(ref Message m)
    {
    if (m.Msg == WM_NCHITTEST)
    {
    base.WndProc(ref m);
    if (m.Result == HTCLIENT)
    {
    m.HWnd = this.Handle; System.Drawing.Rectangle rect = this.RectangleToScreen(this.ClientRectangle);
    Point C_Pos = Cursor.Position;
    m.Result = HTCAPTION;//模拟标题栏,移动或双击可以最大或最小化窗体
    }
    }
    else if (m.Msg == 0xa3)
    {
    return;
    }
    else
    {
    base.WndProc(ref m);
    }
    }
      

  6.   

    zswang(伴水清清)(专家门诊清洁工) 
    hbxtlhx(平民百姓) 
    你们的代码我都看不懂呀,我这个程序是C#window应用程序啊,你们写的是C#的WINDOWS应用程序代码吗?
      

  7.   

    //添加一个MouseDown事件
    //全部给你贴了
    //人不能菜到这样的地步using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Text;
    using System.Windows.Forms;
    using System.Runtime.InteropServices;namespace WindowsApplication15
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
            }        [DllImport("User32.DLL")]
            public static extern int SendMessage(IntPtr hWnd, uint Msg, int wParam, int iParam);
            [DllImport("User32.DLL")]
            public static extern bool ReleaseCapture();
            public const uint WM_SYSCOMMAND = 0x0112;
            public const int SC_MOVE = 61456;
            public const int HTCAPTION = 2;
            private void Form1_MouseDown(object sender, MouseEventArgs e)
            {
                ReleaseCapture();
                SendMessage(Handle, WM_SYSCOMMAND, SC_MOVE | HTCAPTION, 0);        }
        }
    }
      

  8.   

    窗体移动事件不是有DOWN,MOVE,UP事件吗?down,move我都会写了,但一时想不起up怎么想了?而你给我的答案是什么呀?,55555555我看不懂,难道一个mouseDown就可以了?
      

  9.   

    <div  id='calendar' onMouseDown='catchCalendar(this)' onMouseUp='releaseCalendar(this)'>//*******************************************   Move  **********************************************************//
    // 功能:让日历可移动
    // 编码:Dragon Deng
    var IsMove = false;
    var dragClickX = 0;
    var dragClickY = 0;function catchCalendar(e){
    IsMove = true;
    dragClickX=event.clientX-parseInt(document.getElementById("calendar").style.left);
    dragClickY=event.clientY-parseInt(document.getElementById("calendar").style.top);
    document.getElementById("calendar").setCapture();
    document.onmousemove = moveCalendar;
    }function releaseCalendar(e){
    IsMove = false;
    document.getElementById("calendar").releaseCapture();
    document.onmousemove = null;
    hideElement( 'SELECT', document.getElementById("calendar") );
    hideElement( 'APPLET', document.getElementById("calendar") );
    }function moveCalendar(e){
    if(IsMove){
    document.getElementById("calendar").style.left =event.clientX-dragClickX;
    document.getElementById("calendar").style.top = event.clientY-dragClickY;
    document.getElementById("calendar").style.visible = 'show'   
    }
                 
    }
    // 
    //*******************************************  end   ***********************************************************//
      

  10.   

    private void Form1_MouseUp(object sender,System.Windows.Forms.MouseEventArg e)
    {
        int nX=e.x;
        int nY=e.y;
        this.Width=nX;
        this.Height=nY;
    }