Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Clipboard in .NET

Status
Not open for further replies.

Dinobrago

Technical User
Dec 8, 2001
184
US
I am trying to use the clipboard to copy from simple viewer & paste into MS Word.

All appears to be working internally but if I copy onto the clipboard, no other application can paste the copied image.

I can write the meta file to a file, that works fine. I can GetData from the Clipboard within the program, that works (see below). But no other application recognizes that I have copied something onto the clipboard.

Any ideas?

Dean

Imports System
Imports System.Drawing
Imports System.Drawing.Imaging
Imports System.Windows.Forms
Imports System.IO

Class Clip
Inherits Form

ReadOnly ms As MemoryStream = New MemoryStream()

Shared Shadows Sub Main()
Application.Run(New Clip())
End Sub

Readonly ms as MemoryStream = new MemoryStream()
Sub New()

Dim grfx As Graphics = CreateGraphics()
Dim ipHdc As IntPtr = grfx.GetHdc()
Dim mf = New Metafile(ms, ipHdc)
grfx.ReleaseHdc(ipHdc)
grfx.Dispose()
grfx = Graphics.FromImage(mf)
grfx.DrawEllipse(New Pen(Color.Red), 10, 10, 50, 40)

grfx.Dispose()
Clipboard.SetDataObject(mf, True)

End Sub

Protected Overrides Sub OnPaint(ByVal pea As PaintEventArgs)
Dim data As IDataObject = Clipboard.GetDataObject()

If data.GetDataPresent(GetType(Metafile)) Then
Dim mf As Metafile = DirectCast(data.GetData(GetType(Metafile)), Metafile)
pea.Graphics.DrawImage(mf, 0, 0, mf.Width, mf.Height)
End If
End Sub
End Class
Dean
---
goddette@san.rr.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top