CLIPBOARD_VB.NET

gillardg Messages postés 3275 Date d'inscription jeudi 3 avril 2008 Statut Membre Dernière intervention 14 septembre 2014 - 30 sept. 2009 à 12:57
gillardg Messages postés 3275 Date d'inscription jeudi 3 avril 2008 Statut Membre Dernière intervention 14 septembre 2014 - 30 sept. 2009 à 20:45
Cette discussion concerne un article du site. Pour la consulter dans son contexte d'origine, cliquez sur le lien ci-dessous.

https://codes-sources.commentcamarche.net/source/50620-clipboard-vb-net

gillardg Messages postés 3275 Date d'inscription jeudi 3 avril 2008 Statut Membre Dernière intervention 14 septembre 2014 2
30 sept. 2009 à 20:45
magnifique :)
cs_Le Pivert Messages postés 7903 Date d'inscription jeudi 13 septembre 2007 Statut Contributeur Dernière intervention 11 mars 2024 137
30 sept. 2009 à 18:42
Tu as raison il y a d'autres manières de procéder, en voici une:
Un Form, un label et une picture box, tu met le code suivant que j'ai adapté du site: 'http://jo0ls-dotnet-stuff.blogspot.com/search/label/SetClipBoardViewer

Option Strict On
Option Explicit On
Imports System.Runtime.InteropServices
Public Class Form1
Private Const WM_DRAWCLIPBOARD As Integer = &H308
Private Const WM_CHANGECBCHAIN As Integer = &H30D
Private mNextClipBoardViewerHWnd As IntPtr
Private Event OnClipboardChanged()
<DllImport("user32")> _
Private Shared Function SetClipboardViewer(ByVal hWnd As IntPtr) As IntPtr
End Function
<DllImport("user32")> _
Private Shared Function ChangeClipboardChain(ByVal hWnd As IntPtr, ByVal hWndNext As IntPtr) As _
<MarshalAs(UnmanagedType.Bool)> Boolean
End Function
<DllImport("user32")> _
Private Shared Function SendMessage(ByVal hWnd As IntPtr, ByVal msg As Integer, ByVal wParam As IntPtr, _
ByVal lParam As IntPtr) As IntPtr
End Function
Sub New()
InitializeComponent()
mNextClipBoardViewerHWnd = SetClipboardViewer(Me.Handle)
AddHandler Me.OnClipboardChanged, AddressOf ClipBoardChanged
End Sub
Protected Overrides Sub WndProc(ByRef m As Message)
Select Case m.Msg
Case WM_DRAWCLIPBOARD
RaiseEvent OnClipboardChanged()
SendMessage(mNextClipBoardViewerHWnd, m.Msg, m.WParam, m.LParam)
Case WM_CHANGECBCHAIN
If m.WParam.Equals(mNextClipBoardViewerHWnd) Then
mNextClipBoardViewerHWnd = m.LParam
Else
SendMessage(mNextClipBoardViewerHWnd, m.Msg, m.WParam, m.LParam)
End If
End Select
MyBase.WndProc(m)
End Sub
Private Sub ClipBoardChanged()

If Clipboard.ContainsText = True Then
Label1.Text = Clipboard.GetText
End If

If Clipboard.ContainsImage = True Then
PictureBox1.Image = CType(Clipboard.GetImage.Clone, Image)
PictureBox1.SizeMode = PictureBoxSizeMode.Zoom

End If
End Sub
Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As FormClosingEventArgs) Handles Me.FormClosing
ChangeClipboardChain(Me.Handle, mNextClipBoardViewerHWnd)
End Sub

End Class
Tu as le contenu en temps réel.
@+
gillardg Messages postés 3275 Date d'inscription jeudi 3 avril 2008 Statut Membre Dernière intervention 14 septembre 2014 2
30 sept. 2009 à 14:41
lol moi non plus je ne suis pas très C#
alors j'utilise Instant VB
convertis C# code en VB ( et fonctionne très bien )
http://www.tangiblesoftwaresolutions.com/Product_Details/Instant_VB.html

a+
cs_Le Pivert Messages postés 7903 Date d'inscription jeudi 13 septembre 2007 Statut Contributeur Dernière intervention 11 mars 2024 137
30 sept. 2009 à 14:29
Bonjour GILLARDG,
Cela doit être certainement très intéressant, mais je ne programme pas en C# et je ne peux donc pas l'ouvrir, si tu pouvais m'indiquer une source en VB.Net, je suis preneur pour l'étudier et voir les avantages.
@+ Le Pivert
gillardg Messages postés 3275 Date d'inscription jeudi 3 avril 2008 Statut Membre Dernière intervention 14 septembre 2014 2
30 sept. 2009 à 12:57
bonjour ,
il n'est pas nécessaire d'utiliser un timer pour savoir si le contenu du clipboard à changé

http://www.csharpfr.com/codes/CLIPBOARDSPY-ESPIONNER-PRESSE-PAPIER-TOUT-SIMPLEMENT_35649.aspx
Rejoignez-nous