Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Text;
- using System.Windows.Forms;
- using System.Runtime.InteropServices;
- namespace WindowsFormsApplication2
- {
- public partial class BarraSms : Form
- {
- public const int WM_NCLBUTTONDOWN = 0xA1;
- public const int HT_CAPTION = 0x2;
- [DllImportAttribute("user32.dll")]
- public static extern int SendMessage(IntPtr hWnd, int Msg, IntPtr wParam, IntPtr lParam);
- [DllImportAttribute("user32.dll")]
- public static extern bool ReleaseCapture();
- public BarraSms()
- {
- FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
- MyPanel p = new MyPanel();
- p.BackColor = Color.Red;
- p.Size = new System.Drawing.Size(100, 100);
- p.MouseMove += new MouseEventHandler(p_MouseMove);
- Controls.Add(p);
- }
- void p_MouseMove(object sender, MouseEventArgs e)
- {
- if (e.Button == System.Windows.Forms.MouseButtons.Left)
- {
- ReleaseCapture();
- SendMessage(this.Handle, WM_NCLBUTTONDOWN, new IntPtr(HT_CAPTION), IntPtr.Zero);
- }
- }
- }
- public class MyPanel : System.Windows.Forms.Panel
- {
- // NO EVENTS HERE
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement