最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Winform窗體縮放下使用剪切板功能出現(xiàn)頁面閃動(dòng)解決分析

 更新時(shí)間:2023年11月02日 11:02:29   作者:點(diǎn)墨  
這篇文章主要介紹了Winform窗體縮放下使用剪切板功能出現(xiàn)頁面閃動(dòng)解決分析,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪

問題

Winform窗體,在首次使用剪切板功能時(shí)會(huì)出現(xiàn)頁面閃動(dòng)。

原因

使用了PresentionCore.dll里的Clipboard導(dǎo)致的,具體原因未知

解決

使用其他方法進(jìn)行剪切板功能,比如WindowAPI,F(xiàn)orms的Clipboard

演示代碼

MyClipboard.cs

using System;
using System.Runtime.InteropServices;
namespace WindowsFormsApp2
{
    class MyClipboard
    {
        [DllImport("User32")]
        public static extern bool OpenClipboard(IntPtr hWndNewOwner);
        [DllImport("User32")]
        public static extern bool CloseClipboard();
        [DllImport("User32")]
        public static extern bool EmptyClipboard();
        [DllImport("User32")]
        public static extern bool IsClipboardFormatAvailable(int format);
        [DllImport("User32")]
        public static extern IntPtr GetClipboardData(int uFormat);
        [DllImport("User32", CharSet = CharSet.Unicode)]
        public static extern IntPtr SetClipboardData(int uFormat, IntPtr hMem);
        public static void FormsCopy()
        {
            System.Windows.Forms.Clipboard.SetDataObject("Forms");
        }
        public static void PresentationCoreCopy()
        {
            System.Windows.Clipboard.SetDataObject("PresentationCore");
        }
        public static void Win32Copy()
        {
            if (!OpenClipboard(IntPtr.Zero))
            {
                return;
            }
            EmptyClipboard();
            SetClipboardData(13, Marshal.StringToHGlobalUni("Win32"));
            CloseClipboard();
        }
    }
}

Form1.cs

using System;
using System.Collections;
using System.Collections.Concurrent;
using System.Configuration;
using System.IO;
using System.Text;
using System.Windows.Forms;
using System.Text.RegularExpressions;
using System.Diagnostics;
using System.Drawing;
using System.Threading;
namespace WindowsFormsApp2
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            this.WindowState = FormWindowState.Normal;
        }
        private void button1_Click(object sender, EventArgs e)
        {
            MyClipboard.FormsCopy();
        }
        private void button2_Click(object sender, EventArgs e)
        {
            MyClipboard.PresentationCoreCopy();
        }
        private void button1_Click_1(object sender, EventArgs e)
        {
            MyClipboard.Win32Copy();
        }
    }
}

演示效果

以上就是Winform窗體縮放下使用剪切板功能出現(xiàn)頁面閃動(dòng)解決分析的詳細(xì)內(nèi)容,更多關(guān)于Winform窗體縮放的資料請(qǐng)關(guān)注腳本之家其它相關(guān)文章!

相關(guān)文章

最新評(píng)論

营山县| 盐山县| 建德市| 泉州市| 徐水县| 卫辉市| 西吉县| 沙河市| 汉川市| 喀喇沁旗| 丰台区| 梅河口市| 壤塘县| 彰武县| 左云县| 绥中县| 淮阳县| 山西省| 任丘市| 屏东市| 和硕县| 石嘴山市| 黄平县| 崇左市| 嘉峪关市| 兴宁市| 潮安县| 固阳县| 同心县| 平邑县| 巴塘县| 分宜县| 贵州省| 休宁县| 岐山县| 宝清县| 增城市| 灵寿县| 界首市| 商城县| 团风县|