(C #) SendMessage to create untitled bar windows

Source: Internet
Author: User
Tags prototype definition

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.