控制弹出窗体:如何通过鼠标控制无标头窗体



这个问题也是来自论坛提问同样是.Net WinForm新手问题这样问题如果在Deplphi这样板块立刻就被秒杀了,可是.Net版知道人好像不太多

介绍两个思路方法个是发送SC_Move消息个是改变鼠标区域消息

思路方法:

using ;
using .Collections.Generic;
using .ComponentModel;
using .Data;
using .Drawing;
using .Text;
using .Windows.Forms;
using .Runtime.InteropServices;
WindowsApplication1
{
public partial Form1 : Form
{
public Form1
{
InitializeComponent;
}
[DllImport("user32.dll", EntryPo = "SendMessage")]
public extern SendMessage( hWnd, wMsg, wParam, lParam);
[DllImport("user32.dll", EntryPo = "ReleaseCapture")]
public extern ReleaseCapture;
public const WM_SysCommand = 0x0112;
public const SC_MOVE = 0xF012;


private void Form1_MouseDown(object sender, MouseEventArgs e)
{
ReleaseCapture;
SendMessage(this.Handle.ToInt32, WM_SysCommand, SC_MOVE, 0);
}

private void Form1_Load(object sender, EventArgs e)
{

}
}
}
思路方法 2:

using ;
using .Windows.Forms;
WindowsApplication1
{
public partial Form1 : Form
{
public Form1
{
InitializeComponent;
}

protected override void WndProc(ref Message m)
{
base.WndProc(ref m); (m.Msg 0x84)
{
switch (m.Result.ToInt32)
{
1:

m.Result = IntPtr(2); ;
}
}
}
}
}
Tags:  标头设计 网页标头 网站标头 控制弹出窗体

延伸阅读

最新评论

发表评论