• Winform控件扩展


    1.TextBox 增加水印

    新增一个用户控件,将继承UserControl改为TextBox

    public partial class TextBoxEP : TextBox
        {
            public TextBoxEP()
            {
                InitializeComponent();
            }
    
            private const uint WT_Mark = 0x1501;
    
            [DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = false)]
            static extern IntPtr SendMessage(IntPtr hWnd, uint Msg, uint wParam, [MarshalAs(UnmanagedType.LPWStr)] string lParam);
    
            private string watermarkText;
    
            [Description("水印文字")]
            public string WatermarkText
            {
                get { return watermarkText; }
                set
                {
                    watermarkText = value;
                    SetWatermark(watermarkText);
                }
            }
    
            private void SetWatermark(string watermarkText)
            {
                SendMessage(this.Handle, WT_Mark, 0, watermarkText);
            }
        }
  • 相关阅读:
    poj3411
    2241 排序二叉树
    1004 四子连棋
    Poj1482
    poj2046
    Poj3087
    poj3414
    php使用flock堵塞写入文件和非堵塞写入文件
    HTML样式以及使用
    高效程序猿的狂暴之路
  • 原文地址:https://www.cnblogs.com/hualuohuakaihuamanyuan/p/7299456.html
Copyright © 2020-2023  润新知