我有两个图片盒。第一个是图元文件图像,第二个是位图图像。按下按钮后图片在剪贴板中时,我需要查看图片的格式并将其放入相应的图片框中。我接下来做了但由于某种原因它不起作用。请帮帮我。
if (iData.GetDataPresent(DataFormats.MetafilePict)== true )
try
{
if (ClipboardFunctions.OpenClipboard(this.Handle))
{
if (ClipboardFunctions.IsClipboardFormatAvailable(CF_ENHMETAFILE) != 0) //CF_ENHMETAFILE=14
{
IntPtr intptr = ClipboardFunctions.GetClipboardData(CF_ENHMETAFILE);
pictureBox2.SizeMode = PictureBoxSizeMode.Zoom;
pictureBox2.Image = new System.Drawing.Imaging.Metafile(intptr, true);
}
}
}
finally { ClipboardFunctions.CloseClipboard(); }
else if (iData.GetDataPresent(DataFormats.Bitmap) == true)
pictureBox1.Image = Clipboard.GetImage();