第一个Clipboard.GetImage()调用工作;后续的Clipboard.GetImage()调用返回null ...直到我再次执行复制。 [英] First Clipboard.GetImage() call works; subsequent Clipboard.GetImage() calls return null... until I do the Copy again.

查看:142
本文介绍了第一个Clipboard.GetImage()调用工作;后续的Clipboard.GetImage()调用返回null ...直到我再次执行复制。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的测试中复制&在我的.NET应用程序和许多其他Windows应用程序之间粘贴功能,我注意到有些消息来源将Bitmaps放在剪贴板上,这样我第一次访问Clipboard.GetImage()它就在那里,但如果我尝试
再次访问Clipboard.GetImage()它返回null!

In my testing the Copy & Paste functionality between my .NET app and lots of other Windows apps, I have noticed that some sources put Bitmaps on the Clipboard in such a way that the first time I access Clipboard.GetImage() it is there, but if I try to access Clipboard.GetImage() again it returns null!

如果我在VS调试器中中断并跳过该行:

If I break in the VS debugger and step over the line:

Image clipImage = Clipboard.GetImage();

并检查'clipImage',我看到一个不错的Bitmap。  但是如果我再次将执行拖回到该行并再次按Step Over,则'clipImage'为空。  所以,这不是我在第一个Clipboard.GetImage()之后所做的事情......它就是那个调用本身。

and check 'clipImage', I see a nice Bitmap.  But if I drag execution back to that line again and press Step Over again, then 'clipImage' is null.  So, it is not anything that I am doing after the first Clipboard.GetImage()... it is that call itself.

如果我从其他来源复制,包括我自己的复制命令,我没有看到这种行为。  我可以一遍又一遍地调用Clipboard.GetImage()并且它总是返回相同的东西。

If I copy from other sources, including my own Copy commands, I do NOT see this behavior.  I can call Clipboard.GetImage() over and over and it always returns the same thing.

然而,这不仅仅是那些复制错误的来源的问题...如果我从该源粘贴到非.NET程序(如Wordpad),我可以反复粘贴而不会出现问题。

However, it is NOT just an issue with those sources copying wrong... if I paste from that source into non .NET programs (like Wordpad), I can paste over and over again without problem.

有人看过这种行为吗?  任何人都可以解释一下吗?  或者提供解决方案?  谢谢!

Anyone seen this behavior?  Can anyone explain it?  Or give a work-around?  Thanks!

推荐答案

您好TCC开发者,

Hi TCC Developer,

您能否告诉我们怎么样?我们重现了这个问题?

Could you please show us how can we reproduce this issue?

我正在使用以下代码进行测试,一切正常。图片框中的图片目前显示。

I'm using the following code to test, everything works fine. The image in picturebox shows currently.

public partial class Form1 : Form
{
    public Form1()
    {
        InitializeComponent();
    }

    private void button1_Click(object sender, EventArgs e)
    {
        Image clipImage = Clipboard.GetImage();
        Image clipImage2 = Clipboard.GetImage();
        pictureBox1.Image = clipImage2;
    }

    private void button2_Click(object sender, EventArgs e)
    {
        Clipboard.Clear();
        pictureBox1.Image = null;
        //Clipboard.SetImage(Properties.Resources.Chrysanthemum);
        Clipboard.SetDataObject(Properties.Resources.Chrysanthemum);
    }
}

最好的问候,


这篇关于第一个Clipboard.GetImage()调用工作;后续的Clipboard.GetImage()调用返回null ...直到我再次执行复制。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆