解决方案 »
- 可以把.netframework4打包进我的安装程序吗?
- C#调用access数据,如何更改列宽?
- 关于ComboBox的传值问题?急急急
- Object reference not set to an instance of an object错误,请高手相助
- 如何遍历所有控件?
- 谁来给我讲解下这段程序啊 有关CHAR类型的双重身份
- 在VC#中如何禁止除0-9的键盘输入呢
- 关于visual studio 2010 的帮助
- 菜鸟问题:学习c#.net
- 求C#发送数据包的方法。。
- 问个网站上AutoCompleteExtender调用webservice的问题
- 关于streamwriter的小问题请教~~
{
InitializeComponent();
formwidth = this.Width;
formheight = this.Height;
}
那你也不用真的把宽高变成0吧.
向上缩进,宽度不变,高度应该留一点,QQ也是这样做的.否则你就找不到了,只能鼠标在屏幕上乱划拉.
其他方向同理.
你的代码55,56行可以去掉,因为已经移到窗口初始化那里了。
你确定一下你的窗体的MouseDown,MouseEnter,MouseLeave,Move这四个事件都绑定了代码里面的相应函数了。你在试一下,如果不行,我可以把我的项目上传。
不行额,还是没效果
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Windows.Forms;
using System.Runtime.InteropServices;namespace AutoApp
{
public partial class Form1 : Form
{
[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;
int formwidth;
int formheight;
public Form1()
{
InitializeComponent();
formwidth = this.Width;
formheight = this.Height;
}
private void form_toolStyle_MouseDown(object sender, MouseEventArgs e)
{
ReleaseCapture();
SendMessage(this.Handle, WM_SYSCOMMAND, SC_MOVE + HTCAPTION, 0);
}
private void form_toolStyle_MouseLeave(object sender, EventArgs e)
{
int nowx = Cursor.Position.X;
int nowy = Cursor.Position.Y;
if (nowx >= (this.Location.X + this.Width)
|| nowx <= this.Location.X
|| nowy <= this.Location.Y
|| nowy >= (this.Location.Y + this.Height)
)
{
SetDimension();
}
}
private void form_toolStyle_Move(object sender, EventArgs e)
{
SetDimension();
}
private void form_toolStyle_MouseEnter(object sender, EventArgs e)
{
this.Width = formwidth;
this.Height = formheight;
System.Diagnostics.Debug.Print(this.Location.X.ToString() + ":" + this.Location.Y.ToString());
}
private void SetDimension()
{
int x = this.Location.X;
int y = this.Location.Y;
if (x <= 0)
{
this.Location = new System.Drawing.Point(0, y);
this.Width = 0;
}
if (y <= 0)
{
this.Location = new System.Drawing.Point(x, 0);
this.Height = 0;
}
}
public void SetWindowRegion()
{
GraphicsPath FormPath;
FormPath = new System.Drawing.Drawing2D.GraphicsPath();
Rectangle rect = new Rectangle(-1, -1, this.Width + 1, this.Height);
FormPath = GetRoundedRectPath(rect, 25);
this.Region = new Region(FormPath);
}
private GraphicsPath GetRoundedRectPath(Rectangle rect, int radius)
{
int diameter = radius;
Rectangle arcRect = new Rectangle(rect.Location, new Size(diameter, diameter));
GraphicsPath path = new GraphicsPath();
path.AddArc(arcRect, 185, 90);
arcRect.X = rect.Right - diameter;
path.AddArc(arcRect, 275, 90);
arcRect.Y = rect.Bottom - diameter;
path.AddArc(arcRect, 356, 90);
arcRect.X = rect.Left;
path.AddArc(arcRect, 90, 90);
path.CloseFigure();
return path;
}
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
SetWindowRegion();
}
private void Form1_Load(object sender, EventArgs e)
{
this.FormBorderStyle = FormBorderStyle.None;
}
}
}