一般窗口最小化时都自动的跑到下面的栏里去了    我想改变一下   不如说放在左下角  
   我这样写不对  -_-!
     private void Form1_Resize(object sender, EventArgs e)
        {
            if (this.WindowState == FormWindowState.Minimized)
            {
                this.Location = new Point(0, 700);
            } 
        }
望高人指点

解决方案 »

  1.   

    刚才做了个试验,没有成功。
    this.Location = new Point(0,70);
    this.Size.Width=50;
    this.Size.Height=20;
    没有成功,说是this.Size.Width不是变量,不能更改,迷惑了
      

  2.   

    其实问题不是这么简单的,你直接设置location,那么你首先要知道屏幕的大小,这个得到不困难,然后,你要设置位置了,不过这个location,要不要考虑你的窗体的高度呢?如果要,要多高呢?这叫好比我们在MDI主窗体中最小化一个子窗体,那么它是显示在左下角的一样,LZ可以考虑一下!
      

  3.   

    呵呵,你要这么设置this.Size = new Size(50,20);
      

  4.   

            private void Form1_Resize(object sender, EventArgs e)
            {
                if (this.WindowState == FormWindowState.Minimized)
                {
                    this.Location = new Point(0, 700);
                    this.Size = new Size(50, 20); 
                } 
            }这么写的  还是最小化在底下了   当再次点击的时候倒是实现了想要的功能   我感觉应该是要重写这个方法的  可是不知道该怎么写
    高手再指点一下吧
      

  5.   

    csharp_start   我顶你~
      

  6.   

    你这样写试试
    private void Form1_Resize(object sender, EventArgs e) 
            { 
                if (this.WindowState == FormWindowState.Minimized) 
                { 
                    this.Location = new Point(0, 700); 
                    this.Size = new Size(50, 20);  
                    e.cancel=true;
                }  
            } 
      

  7.   

    private void Form1_Resize(object sender, EventArgs e) 
            { 
                if (this.WindowState == FormWindowState.Minimized) 
                { 
                    this.Location = new Point(0, 700); 
                    this.Size = new Size(50, 20);  
                    e.cancel=true;
                }  
            }  没有那个 e.cancel  啊
      

  8.   

    直接设置Form的ShowInTaskbar属性为False就行
    这样最小化后任务栏里没有却会在左下角显示
      

  9.   

    ShowInTaskbar 设置为 false   之后是不显示在任务栏里了  整个窗体也不见了用alt+tab 才能找出这个窗体  找出之后 窗体倒是出现在左下角了   ^_^! 还是稍稍差点   不过还是要谢谢  walkingmu   又多知道一个属性 
      

  10.   

            private void Form1_Resize(object sender, EventArgs e)
            { 
                this.ShowInTaskbar = false;
            }又改了改  这样写的   不过还是那样子  第一次最小化时 窗口就不见了  左下角也没有 -_-!   
    用alt+tab 找出这个窗体  找出之后 窗体倒是出现在左下角了  能不能 在第一次点击最小化之后就直接缩到左下角去呢?
      

  11.   

    private void Form1_SizeChanged(object sender, System.EventArgs e)
    {
    if (this.WindowState == FormWindowState.Minimized)
    {
    this.Width=50;
    this.Height=50;
    this.Location =new System.Drawing.Point(0,600); 
    this.WindowState=FormWindowState.Normal;
    }
    }
      

  12.   

    没有e.cancel的,这么写就可以了.
      

  13.   

    private void Form1_SizeChanged(object sender, System.EventArgs e)
    {
    if (this.WindowState == FormWindowState.Minimized)
    {
    this.Width=50;
    this.Height=50;
    this.Location =new System.Drawing.Point(0,600); 
    this.WindowState=FormWindowState.Normal;
    }
    }这么写看上去是实现了 最小化到左下角  可是当再次点击最小化按钮时 窗口无法恢复原来的大小了
      

  14.   

        public partial class Form1 : Form
        {
            private bool status = false;
            private Point p;
            private Size size;
            private Rectangle rect;        public Form1()
            {
                InitializeComponent();
            }
            private void Form1_Resize(object sender, EventArgs e)
            {
                if (this.WindowState == FormWindowState.Minimized)
                {
                    this.ShowInTaskbar = false;
                    if (status==false)
                    {
                        this.Location = new Point(0,this.rect.Height-50);
                        this.Size = new Size(50, 20);
                        status = true;
                    }
                    else
                    {
                        this.Location = this.p;
                        this.Size = this.size;
                        status = false;
                    }
                }            this.WindowState = FormWindowState.Normal;
            }        private void Form1_Load(object sender, EventArgs e)
            {
                this.p = this.Location;
                this.size = this.Size;
                this.rect = System.Windows.Forms.SystemInformation.VirtualScreen; 
            }
        }
    }我这么着给搞定了  ^_^ 
    不过在 Y轴 定位上还是不太好 (手动试验出来的坐标)
    请问怎么样才能够 恰当的 在窗口最小化时放在 开始 上面 (即使分辨率改变了也没关系 照样能恰当的放在开始额上面)还有 我感觉这么写有点费劲  MS应该有某个设置吧  ^_^    高手再点点
      

  15.   

    你可以做到这一点,方法是把你的窗体做为“桌面”的子窗体就可以了。就像Mdi类型的子窗体一样。
      

  16.   

    参考代码如下:
    [DllImport("user32.dll", CharSet = CharSet.Auto, ExactSpelling = true)]
    public static extern IntPtr GetDesktopWindow();protected override void OnLoad(EventArgs e)
    {
    base.OnLoad(e);
    IntPtr handle = GetDesktopWindow();
    if (handle != IntPtr.Zero)
    {
    SetParent(this.Handle, handle);
    }
    }
      

  17.   

    上面的代码加上如下的API声明:[DllImport("user32.dll", CharSet = CharSet.Auto, ExactSpelling = true)]
    public static extern IntPtr SetParent(IntPtr hWnd, IntPtr hWndParent);[DllImport("user32.dll", CharSet = CharSet.Auto, ExactSpelling = true)]
    public static extern IntPtr GetDesktopWindow();protected override void OnLoad(EventArgs e)
    {
        base.OnLoad(e);
        IntPtr handle = GetDesktopWindow();
        if (handle != IntPtr.Zero)
        {
            SetParent(this.Handle, handle);
        }
    }
      

  18.   

    你直接将mdi窗体设置为图标栏显示
    然后在将其设置为任务栏不显示,就可以了。如果你想用代码实现的话,就要用到api了
      

  19.   

    -_-!(刚看C#没2周)     hbxtlhx 的解释太深奥了
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;
    using System.Runtime.InteropServices;namespace minni
    {
        public partial class Form2 : Form
        {
            public Form2()
            {
                InitializeComponent();
            }        [DllImport("user32.dll", CharSet = CharSet.Auto, ExactSpelling = true)]
            public static extern IntPtr SetParent(IntPtr hWnd, IntPtr hWndParent);        [DllImport("user32.dll", CharSet = CharSet.Auto, ExactSpelling = true)]
            public static extern IntPtr GetDesktopWindow();        //重写
            protected override void OnLoad(EventArgs e)
            {
                base.OnLoad(e);
                IntPtr handle = GetDesktopWindow();
                if (handle != IntPtr.Zero)
                {
                    SetParent(this.Handle, handle);
                }
            }
        }
    }不知道这样写对么   如果对的话  好像没有启作用  或者是我代码贴错位置了  望 hbxtlhx 指点
      

  20.   

    hbxtlhx不好意思   是我忘记设置ShowInTaskbar了  抱歉啊   谢谢你的帮助