Exemple #1
0
        /// <summary>
        /// 设置窗口无边框
        /// </summary>
        /// <param name="hWnd">窗口句柄</param>
        public static void SetWindowNoBorder(IntPtr hWnd)
        {
            var wndStyle = (long)Win32Funcs.GetWindowLongWrapper(hWnd, Win32Consts.GWL_STYLE);

            wndStyle &= ~Win32Consts.WS_CAPTION;
            wndStyle &= ~Win32Consts.WS_THICKFRAME;
            //WS_BORDER,WS_DLGFRAME;
            Win32Funcs.SetWindowLongWrapper(hWnd, Win32Consts.GWL_STYLE, (int)wndStyle);
        }
Exemple #2
0
        /// <summary>
        /// 设置窗口透明度
        /// </summary>
        /// <param name="hWnd">窗口句柄</param>
        /// <param name="alpha">透明度</param>
        public static void SetWindowAlpha(IntPtr hWnd, byte alpha)
        {
            //在调用SetLayeredWindowAttributes 之前,需要给窗口加上WS_EX_LAYERED属性,否则会无效
            var wndExStyle = Win32Funcs.GetWindowLongWrapper(hWnd, Win32Consts.GWL_EXSTYLE);

            wndExStyle |= Win32Consts.WS_EX_LAYERED;
            Win32Funcs.SetWindowLongWrapper(hWnd, Win32Consts.GWL_EXSTYLE, wndExStyle);

            //设置透明度
            Win32Funcs.SetLayeredWindowAttributesWrapper(hWnd, 0, alpha, Win32Consts.LWA_ALPHA);
        }