窗体移动API

//窗体移动API
[DllImport("user32.dll")]
public static extern bool ReleaseCapture();
[DllImport("user32.dll")]
public static extern bool SendMessage(IntPtr hwnd, int wMsg, int wParam, int IParam);
public const int WM_SYSCOMMAND = 0x0112;
public const int SC_MOVE = 0xF010;
public const int HTCAPTION = 0x0002;
[DllImport("user32")]
private static extern int SendMessage(IntPtr hwnd, int wMsg, int wParam, IntPtr lParam);
private const int WM_SETREDRAW = 0xB;

private void Form1_MouseDown(object sender, MouseEventArgs e)
{
    if (this.WindowState == FormWindowState.Normal)
    {
        ReleaseCapture();
        SendMessage(this.Handle, WM_SYSCOMMAND, SC_MOVE + HTCAPTION, 0);
    }
}
时间: 2024-10-03 16:34:16

窗体移动API的相关文章

窗体移动 窗体阴影API

窗体移动API //窗体移动API [DllImport("user32.dll")] public static extern bool ReleaseCapture(); [DllImport("user32.dll")] public static extern bool SendMessage(IntPtr hwnd, int wMsg, int wParam, int IParam); public const int WM_SYSCOMMAND = 0x

【2017-4-27】Winform 窗体移动API 窗体阴影API

窗体移动API //窗体移动API [DllImport("user32.dll")] public static extern bool ReleaseCapture(); [DllImport("user32.dll")] public static extern bool SendMessage(IntPtr hwnd, int wMsg, int wParam, int IParam); public const int WM_SYSCOMMAND = 0x

C# 窗体常用API函数 应用程序窗体查找

常用的处理窗体的API函数如下(注意:API函数必须放在窗体中...): 使用C#语言,要引用DllImport,必须要添加using System.Runtime.InteropServices命名空间 (1)获得当前前台窗体句柄 [DllImport("user32.dll", CharSet = CharSet.Auto, ExactSpelling = true)] public static extern IntPtr GetForegroundWindow(); 返回值类型

Vb.net/VB 声明API函数实现父窗体功能

回顾第一次敲机房收费,自己调用了api函数实现了父窗体及其子窗体最小化的功能,如今再次遇到,自己就在思考,能不能继续使用API函数呢?答案当然是Of Course! 其实仔细看两者并没有多大的区别,先看看在vb.net中如何调用: 首先添加一个类模块,来封装此API函数: <span style="font-size:14px;"> Public Declare Function SetParent Lib "<span style="color:

C#-WinForm-无边框窗体的移动和阴影-API

//窗体移动API,先导入命名空间,在委托MouseDown事件 //移动前准备 [DllImport("user32.dll")] public static extern bool ReleaseCapture(); [DllImport("user32.dll")] public static extern bool SendMessage(IntPtr hwnd, int wMsg, int wParam, int IParam); public const

WinForm 窗体API移动 API阴影

窗体移动 //窗体移动API [DllImport("user32.dll")] public static extern bool ReleaseCapture(); [DllImport("user32.dll")] public static extern bool SendMessage(IntPtr hwnd, int wMsg, int wParam, int IParam); public const int WM_SYSCOMMAND = 0x011

C语言API编写窗体界面和按钮

        最近有个同学的程序需要用对话框的方式实现,但前面都是通过黑框形式完成的,老师突然让增加一个界面,本来准备采用MFC完成的,但后来一想,该程序核心东西是体现在它的算法上,控制台的程序并非不好.转念一想,如果使用MFC这样的方法好像需要再倒腾一遍,想到了大一在"C语言能干大事"中的东西,所以就准备采用这种形式直接完成,投机取巧的方法. 主要是通过调用Windows API界面的CreateWindows函数完成,同时也能创建按钮,把参数设置为button,如果想响应该按钮,

WINFORM 无边框窗体 阴影与移动

//窗体移动API[DllImport("user32.dll")]public static extern bool ReleaseCapture();[DllImport("user32.dll")]public static extern bool SendMessage(IntPtr hwnd, int wMsg, int wParam, int IParam);public const int WM_SYSCOMMAND = 0x0112;public c

winform 移动窗体,和窗体阴影(引用)

无边框窗体移动://窗体移动API [DllImport("user32.dll")] public static extern bool ReleaseCapture(); [DllImport("user32.dll")] public static extern bool SendMessage(IntPtr hwnd, int wMsg, int wParam, int IParam); public const int WM_SYSCOMMAND = 0x