1 - Saber si el portapapeles contiene una imagen con la función ContainsImage
Option Explicit On
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
If My.Computer.Clipboard.ContainsImage() = True Then
MsgBox("Contiene imagen")
Else
MsgBox("No Contiene imagen")
End If
End Sub
End Class
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
If My.Computer.Clipboard.ContainsImage() = True Then
MsgBox("Contiene imagen")
Else
MsgBox("No Contiene imagen")
End If
End Sub
End Class
2 - Establecer y obtener una imagen - Función GetImage
Option Explicit On
Imports System.Windows.Forms.SendKeys
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
With My.Computer.Clipboard
' envía la pulsación de la tecla print screen
SendKeys.Send("{PRTSC}")
' recupera la imagen
Me.BackgroundImage = .GetImage()
End With
End Sub
End Class
Imports System.Windows.Forms.SendKeys
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
With My.Computer.Clipboard
' envía la pulsación de la tecla print screen
SendKeys.Send("{PRTSC}")
' recupera la imagen
Me.BackgroundImage = .GetImage()
End With
End Sub
End Class
3 - Saber si hay texto almacenado - ContainsText
Option Explicit On
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
If My.Computer.Clipboard.ContainsText() = True Then
MsgBox("Hay texto")
Else
MsgBox("No hay texto")
End If
End Sub
End Class
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
If My.Computer.Clipboard.ContainsText() = True Then
MsgBox("Hay texto")
Else
MsgBox("No hay texto")
End If
End Sub
End Class
4 - Saber si hay archivos - ContainsFileDropList
Option Explicit On
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
If My.Computer.Clipboard.ContainsFileDropList() = True Then
MsgBox("Hay archivos")
Else
MsgBox("No hay archivos")
End If
End Sub
End Class
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
If My.Computer.Clipboard.ContainsFileDropList() = True Then
MsgBox("Hay archivos")
Else
MsgBox("No hay archivos")
End If
End Sub
End Class
5 - Obtener los archivos - GetFileDropList
Option Explicit On
Imports System.Collections.Specialized
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object,ByVal e As System.EventArgs) _
Handles MyBase.Load
Dim lista As StringCollection
Dim sArchivos As String = ""
' verifica si hay archivos
If Clipboard.ContainsFileDropList Then
'obtiene
lista = Clipboard.GetFileDropList
ListBox1.Items.Clear()
' los agrega al listbox
For Each sArchivos In lista
ListBox1.Items.Add(sArchivos).ToString()
Next
End If
End Sub
End Class
Imports System.Collections.Specialized
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object,ByVal e As System.EventArgs) _
Handles MyBase.Load
Dim lista As StringCollection
Dim sArchivos As String = ""
' verifica si hay archivos
If Clipboard.ContainsFileDropList Then
'obtiene
lista = Clipboard.GetFileDropList
ListBox1.Items.Clear()
' los agrega al listbox
For Each sArchivos In lista
ListBox1.Items.Add(sArchivos).ToString()
Next
End If
End Sub
End Class
6 - Colocar o establecer archivos - SetFileDropList
Option Explicit On
Imports System.Collections.Specialized
Imports System.IO.File
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs)Handles MyBase.Load
Dim sFile1 As String = "c:\archivo1.txt"
Dim sFile2 As String = "c:\archivo2.txt"
Dim lista As New StringCollection
Try
' verifica si existen
If Exists(sFile1) And Exists(sFile2) Then
' Los agrega a la lista
lista.Add(sFile1)
lista.Add(sFile2)
' los establece
Clipboard.SetFileDropList(lista)
Else
MsgBox("La ruta de los archivos no es válida",MsgBoxStyle.Critical)
End If
Catch mensaje As Exception
MsgBox(mensaje.Message)
End Try
End Sub
End Class
Imports System.Collections.Specialized
Imports System.IO.File
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs)Handles MyBase.Load
Dim sFile1 As String = "c:\archivo1.txt"
Dim sFile2 As String = "c:\archivo2.txt"
Dim lista As New StringCollection
Try
' verifica si existen
If Exists(sFile1) And Exists(sFile2) Then
' Los agrega a la lista
lista.Add(sFile1)
lista.Add(sFile2)
' los establece
Clipboard.SetFileDropList(lista)
Else
MsgBox("La ruta de los archivos no es válida",MsgBoxStyle.Critical)
End If
Catch mensaje As Exception
MsgBox(mensaje.Message)
End Try
End Sub
End Class
7 - Eliminar todo el contenido - Función Clear
Option Explicit On
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
My.Computer.Clipboard.Clear()
End Sub
End Class
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
My.Computer.Clipboard.Clear()
End Sub
End Class
8 - Leer y guardar texto plano - setText y getText
Option Explicit On
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
My.Computer.Clipboard.SetText("un texto", TextDataFormat.Text)
MsgBox(My.Computer.Clipboard.GetText())
End Sub
End Class
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
My.Computer.Clipboard.SetText("un texto", TextDataFormat.Text)
MsgBox(My.Computer.Clipboard.GetText())
End Sub
End Class
9 - guardar un sonido - SetAudio
Option Explicit On
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs)Handles MyBase.Load
Dim Musica As Byte()
Musica = My.Computer.FileSystem.ReadAllBytes("cool.wav")
My.Computer.Clipboard.SetAudio(Musica)
End Sub
End Class
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs)Handles MyBase.Load
Dim Musica As Byte()
Musica = My.Computer.FileSystem.ReadAllBytes("cool.wav")
My.Computer.Clipboard.SetAudio(Musica)
End Sub
End Class
No hay comentarios:
Publicar un comentario