如何通过鼠标控制无标头窗体
这个问题也是来自论坛提问,同样是.Net WinForm新手的问题,这样的问题如果在Deplphi这样的板块立刻就被秒杀了,可是.Net版知道的人好像不太多。介绍两个方法,一个是发送SC_Move消息,一个是改变鼠标区域消息
方法一:
<div class="highlighter">
[*]usingSystem;
[*]usingSystem.Collections.Generic;
[*]usingSystem.ComponentModel;
[*]usingSystem.Data;
[*]usingSystem.Drawing;
[*]usingSystem.Text;
[*]usingSystem.Windows.Forms;
[*]usingSystem.Runtime.InteropServices;
[*]namespaceWindowsApplication1
[*]{
[*]publicpartialclassForm1:Form
[*]{
[*]publicForm1()
[*]{
[*]InitializeComponent();
[*]}
[*]
[*]publicstaticexternintSendMessage(inthWnd,intwMsg,intwParam,intlParam);
[*]
[*]publicstaticexternintReleaseCapture();
[*]publicconstintWM_SysCommand=0x0112;
[*]publicconstintSC_MOVE=0xF012;
[*]
[*]
[*]privatevoidForm1_MouseDown(objectsender,MouseEventArgse)
[*]{
[*]ReleaseCapture();
[*]SendMessage(this.Handle.ToInt32(),WM_SysCommand,SC_MOVE,0);
[*]}
[*]
[*]privatevoidForm1_Load(objectsender,EventArgse)
[*]{
[*]
[*]}
[*]}
[*]}
页:
[1]