窗体最大化以后,窗体不能移动,应如何实现.(C#)

解决方案 »

  1.   

    你把窗口的FormBorderStyle属性设为 System.Windows.Forms.FormBorderStyle.None
    就不能移动了,但是也没有边框了!还有一种方法,就是整个窗口重画,也不能移动!
      

  2.   

    无标题窗体的拖动
    using System;
    using System.Drawing;
    using System.Collections;
    using System.ComponentModel;
    using System.Windows.Forms;
    using System.Data;
    using System.Runtime.InteropServices;  
                      private System.ComponentModel.Container components = null;
                    [STAThread]
    static void Main() 
    {
    Application.Run(new Form1());
    } [DllImport("user32.dll")]
    public static extern bool ReleaseCapture();
    [DllImport("user32.dll")]
    public static extern bool SendMessage(IntPtr hwnd,int wMsg,int wParam,int lParam);
     
    public const int WM_SYSCOMMAND=0x0112;
    public const int SC_MOVE=0xF010;
    public const int HTCAPTION=0x0002;

    private void Form1_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
    {
    ReleaseCapture();
    SendMessage(this.Handle,WM_SYSCOMMAND,SC_MOVE+HTCAPTION, 0); 
    }
      

  3.   

    我把maximizebox属性设为false后,窗体能移动.应如何让他不能移动.
    请问lsj_zrp您说的重画窗体是什么意思.请说详细点.谢谢!!!
      

  4.   

    我把maximizebox属性设为false后,窗体能移动.应如何让他不能移动. 
    ______________________________________________________
    狂晕,maximizebox属性设为false后还能最大化吗?难道你是让它启动是Maximized的。
    如果不是你可以在this.move事件里面添这么一句,不过这样会让窗体有点闪烁
    this.Location = new Point(0, 0);