解决方案 »
- .NET将文件上传到服务器,然后读取并插入到数据库中
- 查询磁盘空间 . 拒绝访问 高手过来帮忙啊 在线等
- 既然接口中的方法必须实现,为什么System.Collections中的接口能直接用?
- 关于LISTVIEW多行删除
- 实现IComparable接口的困惑
- 水晶报表怎么给子报表传递数据?
- 使用xml作为数据库效率的问题
- 得到网页源代码时,为什么整个程序停止响应?
- 50分求学习 XML 的资源,最好结合 .NET 例子
- [原创]IssueVision 学习笔记 兼散分~~
- 求来个高手用C#语言拆分简单的数学表达式
- asp.net页面连续快速刷新几次就出错,错误提示:此文档已具有 'XmlDeclaration' 节点。
private void Form1_MouseDown(object sender, MouseEventArgs e)
{
mPoint.X = e.X;
mPoint.Y = e.Y;
}
private void Form1_MouseMove(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
Point myPosittion = MousePosition;
myPosittion.Offset(-mPoint.X, -mPoint.Y);
Location = myPosittion;
}
}试试。其实我的想法,就是鼠标在移动时,计算窗体的位置就行了
/// 移动窗体
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void MainForm_MouseDown(object sender, MouseEventArgs e)
{ Win32.ReleaseCapture();
Win32.SendMessage(this.Handle, WM_SYSCOMMAND, SC_MOVE + HTCAPTION, 0); }
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;
public static class Win32
{
/// <summary>
/// 释放鼠标操作
/// </summary>
/// <returns></returns>
[DllImport("user32.dll")]
public static extern bool ReleaseCapture();
/// <summary>
/// 发送信息
/// </summary>
/// <param name="hwnd"></param>
/// <param name="wMsg"></param>
/// <param name="wParam"></param>
/// <param name="lParam"></param>
/// <returns></returns>
[DllImport("user32.dll")]
public static extern bool SendMessage(IntPtr hwnd, int wMsg, int wParam, int lParam);
/// <summary>
/// 窗体最小化操作
/// </summary>
/// <param name="hwnd"></param>
/// <returns></returns>
[DllImport("user32.dll")]
public static extern bool CloseWindow(IntPtr hwnd);
/// <summary>
/// 获取窗体状态信息|最小化|最大化|移动|关闭
/// </summary>
/// <param name="hwnd"></param>
/// <param name="nindex"></param>
/// <returns></returns>
[DllImport("user32.dll")]
public static extern int GetWindowLong(HandleRef hwnd, int nindex);
/// <summary>
/// 设置窗体状态信息|最小化|最大化|移动|关闭|系统右键菜单
/// </summary>
/// <param name="hwnd"></param>
/// <param name="nindex"></param>
/// <param name="dwNewLong"></param>
/// <returns></returns>
[DllImport("user32.dll")]
public static extern int SetWindowLong(HandleRef hwnd, int nindex, int dwNewLong);
/// <summary>
/// 获取窗体句柄
/// </summary>
/// <param name="hWnd"></param>
/// <returns></returns>
[System.Runtime.InteropServices.DllImport("user32.dll")]
static extern IntPtr GetWindowDC(IntPtr hWnd);
/// <summary>
/// 释放窗体句柄
/// </summary>
/// <param name="hWnd"></param>
/// <param name="hDC"></param>
/// <returns></returns>
[System.Runtime.InteropServices.DllImport("user32.dll")]
static extern int ReleaseDC(IntPtr hWnd, IntPtr hDC);
}