一般窗口最小化时都自动的跑到下面的栏里去了 我想改变一下 不如说放在左下角
我这样写不对 -_-!
private void Form1_Resize(object sender, EventArgs e)
{
if (this.WindowState == FormWindowState.Minimized)
{
this.Location = new Point(0, 700);
}
}
望高人指点
我这样写不对 -_-!
private void Form1_Resize(object sender, EventArgs e)
{
if (this.WindowState == FormWindowState.Minimized)
{
this.Location = new Point(0, 700);
}
}
望高人指点
this.Location = new Point(0,70);
this.Size.Width=50;
this.Size.Height=20;
没有成功,说是this.Size.Width不是变量,不能更改,迷惑了
{
if (this.WindowState == FormWindowState.Minimized)
{
this.Location = new Point(0, 700);
this.Size = new Size(50, 20);
}
}这么写的 还是最小化在底下了 当再次点击的时候倒是实现了想要的功能 我感觉应该是要重写这个方法的 可是不知道该怎么写
高手再指点一下吧
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;
}
}
{
if (this.WindowState == FormWindowState.Minimized)
{
this.Location = new Point(0, 700);
this.Size = new Size(50, 20);
e.cancel=true;
}
} 没有那个 e.cancel 啊
这样最小化后任务栏里没有却会在左下角显示
{
this.ShowInTaskbar = false;
}又改了改 这样写的 不过还是那样子 第一次最小化时 窗口就不见了 左下角也没有 -_-!
用alt+tab 找出这个窗体 找出之后 窗体倒是出现在左下角了 能不能 在第一次点击最小化之后就直接缩到左下角去呢?
{
if (this.WindowState == FormWindowState.Minimized)
{
this.Width=50;
this.Height=50;
this.Location =new System.Drawing.Point(0,600);
this.WindowState=FormWindowState.Normal;
}
}
{
if (this.WindowState == FormWindowState.Minimized)
{
this.Width=50;
this.Height=50;
this.Location =new System.Drawing.Point(0,600);
this.WindowState=FormWindowState.Normal;
}
}这么写看上去是实现了 最小化到左下角 可是当再次点击最小化按钮时 窗口无法恢复原来的大小了
{
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应该有某个设置吧 ^_^ 高手再点点
[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);
}
}
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);
}
}
然后在将其设置为任务栏不显示,就可以了。如果你想用代码实现的话,就要用到api了
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 指点