First step: Add a reference
Using System.Runtime.InteropServices;
Step two: referencing the API
[DllImportAttribute ("User32.dll")]
public static extern int SendMessage (IntPtr hWnd, int Msg, int wParam, int lParam);
Send message//winuser.h function prototype definition
[DllImportAttribute ("User32.dll")]
public static extern bool ReleaseCapture (); Release mouse capture Winuser.h
Step Three: Write code
Write under the MouseDown of the control:
I. Moving a form (no differences found)
1.
if (E.button = = MouseButtons.Left)
{
ReleaseCapture ();
SendMessage (this. Handle, 274, 61449, 0);
}
2.
if (E.button = = MouseButtons.Left)
{
ReleaseCapture ();
SendMessage (this. Handle, 161, 2, 0);
}
3. (should be the title bar event, click the control when there is a title bar, the mouse immediately move to the title bar position, drag to move the form; If you click the control without the title bar, the mouse immediately moves to the top of the form, and the form is not moved after dragging)
if (E.button = = MouseButtons.Left)
{
ReleaseCapture ();
SendMessage (this. Handle, 274, 61450, 0);
}
Two. Change the size of the form (as in the above method, only the SendMessage method parameter is different)
1. Simulate the left border of a form
SendMessage (this. Handle, 274, 61441, 0);
2. Simulate the right border of a form
SendMessage (this. Handle, 274, 61442, 0);
3. Simulate a border on a form
SendMessage (this. Handle, 274, 61443, 0);
4. Simulate the bottom border of a form
SendMessage (this. Handle, 274, 61446, 0);
5. Simulate the upper left corner of the form
SendMessage (this. Handle, 274, 61444, 0);
6. Simulate the lower left corner of the form
SendMessage (this. Handle, 274, 61447, 0);
7. Simulate the upper right corner of the form
SendMessage (this. Handle, 274, 61445, 0);
8. Simulate the lower-right corner of the form
SendMessage (this. Handle, 274, 61448, 0);
Three. Maximize the minimized form (just like the method called above, only the SendMessage method parameter is different)
1. Simulation form Minimized
SendMessage (this. Handle, 274, 61472, 0);
2. Maximize the Simulation form
SendMessage (this. Handle, 274, 61488,0);
3. Simulate the form to maximize after restore
SendMessage (this. Handle, 274, 61728, 0);
(C #) SendMessage to create untitled bar windows