Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Drawing;
- using System.Windows.Forms;
- using System.Drawing.Drawing2D;
- using System.Runtime.InteropServices;
- namespace WindowsFormsApplication3
- {
- public partial class Form1 : Form
- {
- [DllImport("Gdi32.dll", EntryPoint = "CreateRoundRectRgn")]
- private static extern IntPtr CreateRoundRectRgn
- (
- int nLeftRect, // x-coordinate of upper-left corner
- int nTopRect, // y-coordinate of upper-left corner
- int nRightRect, // x-coordinate of lower-right corner
- int nBottomRect, // y-coordinate of lower-right corner
- int nWidthEllipse, // height of ellipse
- int nHeightEllipse // width of ellipse
- );
- public Form1()
- {
- InitializeComponent();
- Region = System.Drawing.Region.FromHrgn(CreateRoundRectRgn(0, 0, Width, Height, 5, 5));
- }
- protected override void OnLoad(EventArgs e)
- {
- base.OnLoad(e);
- this.FormBorderStyle = FormBorderStyle.None;
- }
- protected override void OnPaintBackground(PaintEventArgs e)
- {
- using (LinearGradientBrush brush = new LinearGradientBrush(this.ClientRectangle,
- Color.LawnGreen,
- Color.Green,
- 90F))
- {
- e.Graphics.FillRectangle(brush, this.ClientRectangle);
- }
- }
- public const int WM_NCLBUTTONDOWN = 0xA1;
- public const int HT_CAPTION = 0x2;
- [System.Runtime.InteropServices.DllImportAttribute("user32.dll")]
- public static extern int SendMessage(IntPtr hWnd, int Msg, int wParam, int lParam);
- [System.Runtime.InteropServices.DllImportAttribute("user32.dll")]
- public static extern bool ReleaseCapture();
- private void Form1_Load(object sender, EventArgs e)
- {
- }
- private void Form1_MouseDown_1(object sender, MouseEventArgs e)
- {
- if (e.Button == MouseButtons.Left)
- {
- ReleaseCapture();
- SendMessage(Handle, WM_NCLBUTTONDOWN, HT_CAPTION, 0);
- }
- }
- private void button1_Click(object sender, EventArgs e)
- {
- this.Close();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement