N
nick
hi
I'm tryin to write a program that keeps track of the contents of the
clipboard to a textbox, but i keep getting "An unhandled exception of
type 'System.NullReferenceException' occurred in
WindowsApplication4.exe" error. here is the sample code
Public Class Form1
Inherits System.Windows.Forms.Form
Public Declare Function SetClipboardViewer Lib "user32" Alias
"SetClipboardViewer" (ByVal hwnd As Long) As Integer
Public Declare Function ChangeClipboardChain Lib "user32" Alias
"ChangeClipboardChain" (ByVal hwnd As Integer, ByVal hWndNext As
Integer) As Integer
Dim hWndClipBoard = SetClipboardViewer(Me.Handle.ToInt32)
Dim strPastedText As String
Private Sub Form1_Closing(ByVal sender As Object, ByVal e As
System.ComponentModel.CancelEventArgs) Handles MyBase.Closing
ChangeClipboardChain(Me.Handle.ToInt32, hWndClipBoard)
End Sub
Protected Overrides Sub WndProc(ByRef m As
System.Windows.Forms.Message)
Const WM_DRAWCLIPBOARD = &H308
Dim data As IDataObject = Clipboard.GetDataObject()
If m.Msg = WM_DRAWCLIPBOARD Then
MessageBox.Show("Here")
If data.GetDataPresent(GetType(String)) Then
strPastedText =
DirectCast(data.GetData(GetType(String)), String)
TextBox1.Text = strPastedText
End If
End If
MyBase.WndProc(m)
End Sub
End Class
I'm tryin to write a program that keeps track of the contents of the
clipboard to a textbox, but i keep getting "An unhandled exception of
type 'System.NullReferenceException' occurred in
WindowsApplication4.exe" error. here is the sample code
Public Class Form1
Inherits System.Windows.Forms.Form
Public Declare Function SetClipboardViewer Lib "user32" Alias
"SetClipboardViewer" (ByVal hwnd As Long) As Integer
Public Declare Function ChangeClipboardChain Lib "user32" Alias
"ChangeClipboardChain" (ByVal hwnd As Integer, ByVal hWndNext As
Integer) As Integer
Dim hWndClipBoard = SetClipboardViewer(Me.Handle.ToInt32)
Dim strPastedText As String
Private Sub Form1_Closing(ByVal sender As Object, ByVal e As
System.ComponentModel.CancelEventArgs) Handles MyBase.Closing
ChangeClipboardChain(Me.Handle.ToInt32, hWndClipBoard)
End Sub
Protected Overrides Sub WndProc(ByRef m As
System.Windows.Forms.Message)
Const WM_DRAWCLIPBOARD = &H308
Dim data As IDataObject = Clipboard.GetDataObject()
If m.Msg = WM_DRAWCLIPBOARD Then
MessageBox.Show("Here")
If data.GetDataPresent(GetType(String)) Then
strPastedText =
DirectCast(data.GetData(GetType(String)), String)
TextBox1.Text = strPastedText
End If
End If
MyBase.WndProc(m)
End Sub
End Class