using System; using System.Collections.Generic; using System.ComponentModel; using System.Drawing; using System.Data; using System.Linq; using System.Text; using System.Windows.Forms; namespace Panely { public partial class MyControl : UserControl { const int WS_OVERLAPPED = 0x00000000; const uint WS_POPUP = 0x80000000; const int WS_CHILD = 0x40000000; const int WS_MINIMIZE = 0x20000000; const int WS_VISIBLE = 0x10000000; const int WS_DISABLED = 0x08000000; const int WS_CLIPSIBLINGS = 0x04000000; const int WS_CLIPCHILDREN = 0x02000000; const int WS_MAXIMIZE = 0x01000000; const int WS_CAPTION = 0x00C00000; /* WS_BORDER | WS_DLGFRAME */ const int WS_BORDER = 0x00800000; const int WS_DLGFRAME = 0x00400000; const int WS_VSCROLL = 0x00200000; const int WS_HSCROLL = 0x00100000; const int WS_SYSMENU = 0x00080000; const int WS_THICKFRAME = 0x00040000; const int WS_GROUP = 0x00020000; const int WS_TABSTOP = 0x00010000; const int WS_MINIMIZEBOX = 0x00020000; const int WS_MAXIMIZEBOX = 0x00010000; const int WS_TILED = WS_OVERLAPPED; const int WS_ICONIC = WS_MINIMIZE; const int WS_SIZEBOX = WS_THICKFRAME; // const int WS_TILEDWINDOW =WS_OVERLAPPEDWINDOW; protected override CreateParams CreateParams { get { // new SecurityPermission(SecurityPermissionFlag.UnmanagedCode).Demand(); // Extend the CreateParams property of the Button class. CreateParams cp = base.CreateParams; // Update the button Style. // cp.Style |= 0x00000040; // BS_ICON value cp.Style |= WS_THICKFRAME /* | WS_CAPTION | WS_MINIMIZEBOX | WS_SYSMENU */; return cp; } } private static int citac = 0; public MyControl() { InitializeComponent(); // ContextMenuStrip = contextMenuStrip1; citac ++; button1.Text = "" + citac; } private void button1_Click(object sender, EventArgs e) { button1.Text = "Click"; } int x0, y0; bool click = false; private void MyControl_MouseDown(object sender, MouseEventArgs e) { x0 = e.X; y0 = e.Y; click = true; } private void MyControl_MouseMove(object sender, MouseEventArgs e) { if (click) { if (e.Button == MouseButtons.Left) { Point t = Location; t.X += e.X - x0; t.Y += e.Y - y0; Location = t; /* Point t = Location; t.Offset (e.X - x0, e.Y - y0); Location = t; */ } else if (e.Button == MouseButtons.Middle) { Size s = Size; s.Width += e.X - x0; s.Height += e.Y - y0; Size = s; x0 = e.X; y0 = e.Y; } } } private void MyControl_MouseUp(object sender, MouseEventArgs e) { click = false; } private void contextMenuStrip1_Opening(object sender, CancelEventArgs e) { } private void toolStripMenuItem1_Click(object sender, EventArgs e) { colorDialog1.Color = BackColor; if (colorDialog1.ShowDialog () == DialogResult.OK) BackColor = colorDialog1.Color; } private void toolStripMenuItem2_Click(object sender, EventArgs e) { if (openFileDialog1.ShowDialog() == DialogResult.OK) { Bitmap b = new Bitmap(openFileDialog1.FileName); BackgroundImage = new Bitmap (b, Width, Height); } } } }