Advertisement
Guest User

Untitled

a guest
Nov 29th, 2013
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.38 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Text;
  7. using System.Windows.Forms;
  8. using System.Runtime.InteropServices;
  9.  
  10. namespace WindowsFormsApplication2
  11. {
  12.     public partial class BarraSms : Form
  13.     {
  14.         public const int WM_NCLBUTTONDOWN = 0xA1;
  15.         public const int HT_CAPTION = 0x2;
  16.  
  17.         [DllImportAttribute("user32.dll")]
  18.         public static extern int SendMessage(IntPtr hWnd, int Msg, IntPtr wParam, IntPtr lParam);
  19.         [DllImportAttribute("user32.dll")]
  20.         public static extern bool ReleaseCapture();  
  21.  
  22.         public BarraSms()
  23.         {
  24.             FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
  25.             MyPanel p = new MyPanel();
  26.             p.BackColor = Color.Red;
  27.             p.Size = new System.Drawing.Size(100, 100);
  28.             p.MouseMove += new MouseEventHandler(p_MouseMove);
  29.             Controls.Add(p);
  30.         }
  31.  
  32.         void p_MouseMove(object sender, MouseEventArgs e)
  33.         {
  34.             if (e.Button == System.Windows.Forms.MouseButtons.Left)
  35.             {
  36.                 ReleaseCapture();
  37.                 SendMessage(this.Handle, WM_NCLBUTTONDOWN, new IntPtr(HT_CAPTION), IntPtr.Zero);
  38.             }
  39.         }
  40.     }
  41.  
  42.     public class MyPanel : System.Windows.Forms.Panel
  43.     {
  44.         // NO EVENTS HERE
  45.     }
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement