Imports System.Threading
Imports System.Windows.Forms
Partial Class utilities_DocAttach
Inherits System.Web.UI.Page
Private Sub btnTest_Click(sender As Object, e As EventArgs) Handles btnTest.Click
Dim cbThread As New Thread(New ThreadStart(AddressOf CopyToClipboard))
cbThread.SetApartmentState(ApartmentState.STA)
cbThread.Start()
cbThread.Join()
End Sub
Sub CopyToClipboard()
If Not System.Windows.Forms.Clipboard.GetDataObject() Is Nothing Then
Dim oDataObj As System.Windows.Forms.IDataObject = System.Windows.Forms.Clipboard.GetDataObject()
If oDataObj.GetDataPresent(System.Windows.Forms.DataFormats.Bitmap) Then
Dim oImgObj As System.Drawing.Image = oDataObj.GetData(DataFormats.Bitmap, True)
'To Save as Bitmap
oImgObj.Save("c:\temp\Test.bmp", System.Drawing.Imaging.ImageFormat.Bmp)
'To Save as Jpeg
oImgObj.Save("c:\temp\Test.jpeg", System.Drawing.Imaging.ImageFormat.Jpeg)
'To Save as Gif
oImgObj.Save("c:\temp\Test.gif", System.Drawing.Imaging.ImageFormat.Gif)
End If
End If
End Sub
End Class