using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Linq;
using System.Security.Permissions;
using System.Text;
using System.Windows.Forms;

namespace ryControls.Controls
{
    /// <summary>
    /// 增强版Label(禁用了双击Label会自动复制文本到剪切板的功能)
    /// </summary>
    [Description("增强版Label(禁用了双击Label会自动复制文本到剪切板的功能)")]
    public partial class LableX : Label
    {
        private const int WM_LBUTTONDBLCLK = 0x203;
        /// <summary>
        /// 
        /// </summary>
        /// <param name="m"></param>
        protected override void WndProc(ref Message m)
        {
            if (m.Msg == WM_LBUTTONDBLCLK)
            {
                string sSaved = Clipboard.GetText();
                System.Drawing.Image iSaved = Clipboard.GetImage();
                base.WndProc(ref m);
                if (iSaved != null) Clipboard.SetImage(iSaved);
                if (!string.IsNullOrEmpty(sSaved)) Clipboard.SetText(sSaved);
            }
            else
            {
                base.WndProc(ref m);
            }
        }
    }
}
