to cocosoft(pengyun),我这里怎么不行啊???

解决方案 »

  1.   

    using System;
    using System.Drawing;
    using System.Collections;
    using System.ComponentModel;
    using System.Windows.Forms;
    using System.Data;namespace WindowsApplication1
    {
    /// <summary>
    /// Form1 的摘要说明。
    /// </summary>
    public class Form1 : System.Windows.Forms.Form
    {
    /// <summary>
    /// 必需的设计器变量。
    /// </summary>
    private System.ComponentModel.Container components = null;
            System.Drawing.Point oldlocation;
    public Form1()
    {
    //
    // Windows 窗体设计器支持所必需的
    //
    InitializeComponent();
                this.oldlocation=new Point ( this.Location.X, this.Location.Y);
    //
    // TODO: 在 InitializeComponent 调用后添加任何构造函数代码
    //
    } /// <summary>
    /// 清理所有正在使用的资源。
    /// </summary>
    protected override void Dispose( bool disposing )
    {
    if( disposing )
    {
    if (components != null) 
    {
    components.Dispose();
    }
    }
    base.Dispose( disposing );
    } #region Windows 窗体设计器生成的代码
    /// <summary>
    /// 设计器支持所需的方法 - 不要使用代码编辑器修改
    /// 此方法的内容。
    /// </summary>
    private void InitializeComponent()
    {
    // 
    // Form1
    // 
    this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
    this.ClientSize = new System.Drawing.Size(392, 266);
    this.Location = new System.Drawing.Point(200, 100);
    this.Name = "Form1";
    this.Text = "Form1";
    this.Move += new System.EventHandler(this.Form1_Move_1); }
    #endregion /// <summary>
    /// 应用程序的主入口点。
    /// </summary>
    [STAThread]
    static void Main() 
    {
    Application.Run(new Form1());
    }
    private void Form1_Move_1(object sender, System.EventArgs e)
    {
      this.Location=new Point(this.oldlocation.X,this.oldlocation.Y);

    }
    }
           这个可以实现,但闪烁比较厉害
      

  2.   

    给你一个参考:
    private void button1_Click(object sender, System.EventArgs e)
    {
    int lSysMenu;
    lSysMenu = WinApi.GetSystemMenu(this.Handle.ToInt32(), 0);

    WinApi.RemoveMenu(lSysMenu, 1, WinApi.MF_BYPOSITION);
    }
    public class WinApi
    {
    public const int MF_BYPOSITION = 1024; [DllImport("User32.dll")]
    public static extern int GetSystemMenu(int hWnd, int bRevert);
    [DllImport("User32.dll")]
    public static extern int RemoveMenu(int hMenu, int nPosition, int wFlags);
    }
      

  3.   

    The following code snippet (posted in the Windows Forms FAQ forums) shows how you can prevent a user from moving a form at run time: 
     
    [C#] 
     
    protected override void WndProc(ref Message m) 
     

     
    const int WM_NCLBUTTONDOWN = 161; 
     
    const int WM_SYSCOMMAND = 274; 
     
    const int HTCAPTION = 2; 
     
    const int SC_MOVE = 61456; 
      
    if((m.Msg == WM_SYSCOMMAND) && (m.WParam.ToInt32() == SC_MOVE)) 
     

     
    return; 
     

      
    if((m.Msg == WM_NCLBUTTONDOWN) && (m.WParam.ToInt32() == HTCAPTION)) 
     

     
    return; 
     

      
    base.WndProc (ref m); 
     

     
      

  4.   

    cocosoft is absolutely right!
    You can also simply set the Form's borderstyle in Visual Studio Design time. Follow this step to test it out: 
    1. Start up Visual Studio Windows (VB/C#) project 
    2. Click on the form, press F4 to bring up the Property Grid 
    3. In the property grid, find the BorderStyle and change it to none. 
    4. Run and test it.
      

  5.   

    //那么麻烦干嘛,就这样搞定:
    protected override void WndProc(ref Message m)
    {
    if (m.Msg==274||m.Msg==2)
    {
    m.Msg=0;
    }
    base.WndProc (ref m);
    }
      

  6.   

    楼主一分都给得出来,I 服了YOU,搞得我们好象讨饭的一样。