This question is also from the forum question, also is the problem of the novice of. Net WinForm, such a problem if in deplphi such plate is immediately killed by seconds, but. NET version of people do not seem to know too much.
Introduces two methods, one is to send Sc_move message, one is to change the mouse region message
Method One:
1.using System;
2.using System.Collections.Generic;
3.using System.ComponentModel;
4.using System.Data;
5.using System.Drawing;
6.using System.Text;
7.using System.Windows.Forms;
8.using System.Runtime.InteropServices;
9.namespace WindowsApplication1
10.{
One. Public partial class Form1:form
12. {
Form1 ()
14. {
InitializeComponent ();
17}
. [DllImport ("user32.dll", EntryPoint = "SendMessage")]
. public static extern int SendMessage (int hWnd, int wmsg, int wParam, int lParam);
[DllImport ("user32.dll", EntryPoint = "ReleaseCapture")]
20. public static extern int releasecapture ();
. public const int wm_syscommand = 0x0112;
. public const int sc_move = 0xf012;
.
.
private void Form1_mousedown (object sender, MouseEventArgs e)
26. {
ReleaseCapture ();
SendMessage (this. Handle.toint32 (), Wm_syscommand, Sc_move, 0);
.}
private void Form1_Load (object sender, EventArgs e)
32. {
A.
34. }
35.
.}
Method Two:
1.using System;
2.using System.Windows.Forms;
3.namespace WindowsApplication1
6.9
5. Public Partial class Form1:form
6. {
7. Public Form1 ()
8. {
9. InitializeComponent ();
Ten }
11.
protected override void WndProc (ref message m)
{
base. WndProc (ref m); If (m.msg = = 0x84)
{
Switch (M.result.toint32 ())
{
Case 1:
19.
M.result = new IntPtr (2); break;
. }
A. }
. }
. }
25.}