FormBorderStyle 的属性我已经设置为 None没有窗体的边框.怎么能拖动窗体??
解决方案 »
- 如何用c#读取邮箱服务器里面的邮件标题跟内容
- toolStripStatusLabel里面的文字滚动
- 在WinForm下,大家有没有做过仿Photoshop的浮动工具箱
- 很简单的一个关于XML的问题,就不多给分了
- 一个关于WEB开发的问题,请用C#,asp.net解决
- 求助:客户端发现响应内容类型为“text/html;charset=GB2312”,但应该是“text/xml”
- 一个关于颜色值转化为无符号整型的问题,好奇怪,请高手帮忙。
- 我现在要用winform(c#)搞个程序要实现同时监控两个不同的数据表,并同时把信息显示到不同的TextBox中,不知是用两个timer控件实现好,还是
- 请问如何取得文件的扩展名
- 有谁熟悉字符串拆分的 请帮帮忙 急啊。。。。。。。
- 请教保存文件的问题
- 请问.RESX的作用?谢谢!
// API
using System.Runtime.InteropServices;[DllImport("User32.DLL")]
public static extern int SendMessage(IntPtr hWnd, uint Msg, int wParam, int lParam);
[DllImport("User32.DLL")]
public static extern bool ReleaseCapture();
public const uint WM_SYSCOMMAND = 0x0112;
public const int SC_MOVE = 61456;
public const int HTCAPTION = 2;private void Form1_MouseDown(object sender, MouseEventArgs e)
{
ReleaseCapture();
SendMessage(Handle, WM_SYSCOMMAND, SC_MOVE | HTCAPTION, 0);
}//---------------
// 消息
protected override void WndProc(ref Message m)
{
const int WM_NCHITTEST = 0x0084;
const int WM_NCLBUTTONDBLCLK = 0x00A3;
const int WM_SYSCOMMAND = 0x0112;
const int HTCLIENT = 1;
const int HTCAPTION = 2;
switch (m.Msg)
{
case WM_NCHITTEST:
base.WndProc(ref m);
if ((int)m.Result == HTCLIENT)
m.Result = (IntPtr)HTCAPTION;
return;
case WM_NCLBUTTONDBLCLK:
return;
}
base.WndProc(ref m);
} //---------------
// 坐标计算
Point downPoint;
private void Form1_MouseDown(object sender, MouseEventArgs e)
{
downPoint = new Point(e.X, e.Y);
}private void Form1_MouseMove(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
Location = new Point(Location.X + e.X - downPoint.X,
Location.Y + e.Y - downPoint.Y);
}
}
public partial class Form1 : Form
{
Point MyOffset;
public Form1()
{
InitializeComponent();
this.MouseDown += new MouseEventHandler(Form1_MouseDown);
this.MouseMove += new MouseEventHandler(Form1_MouseMove);
} void Form1_MouseMove(object sender, MouseEventArgs e)
{
//throw new Exception("The method or operation is not implemented.");
if (e.Button == MouseButtons.Left)
{
Point MyPos = Control.MousePosition;
MyPos.Offset(MyOffset.X, MyOffset.Y);
this.DesktopLocation = MyPos;
}
} void Form1_MouseDown(object sender, MouseEventArgs e)
{
//throw new Exception("The method or operation is not implemented.");
MyOffset = new Point(-e.X, -e.Y);
}
}
代码已经测试通过.
int y;
private void Form1_MouseDown(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
x = e.X;
y = e.Y;
}
} private void Form1_MouseMove(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
this.Left += (e.X - x);
this.Top += (e.Y - y);
}
}