Home All Groups Group Topic Archive Search About
Author
10 Nov 2006 12:22 AM
Newbie
How do I clear the clipboard in VB.NET 2003?

TIA

Newbie

Author
10 Nov 2006 1:23 PM
zacks
Newbie wrote:
> How do I clear the clipboard in VB.NET 2003?
>
> TIA
>
> Newbie

Clipboard.Clear
Author
10 Nov 2006 1:54 PM
Newbie
In VB.NET 2003 the Clipboard only had 2 things

GetDataObject & SetDataObject

So, you are wrong

Anyone know the correct way to do this?

TIA

Newbie

<za***@construction-imaging.com> wrote in message
Show quoteHide quote
news:1163165012.797359.70110@m7g2000cwm.googlegroups.com...
>
> Newbie wrote:
> > How do I clear the clipboard in VB.NET 2003?
> >
> > TIA
> >
> > Newbie
>
> Clipboard.Clear
>
Author
10 Nov 2006 2:35 PM
HKSHK
Dear Newbie,

from the VB.NET 2003 online help:

Clipboard Object Changes in Visual Basic .NET

The Clipboard object in Visual Basic 6.0 has no direct equivalent in
Visual Basic .NET. Although there is no direct mapping, the
functionality of the Clipboard object can be duplicated using the
System.Windows.Forms.Clipboard namespace.

During upgrade, any code that references the Clipboard object is not
upgraded and must be rewritten. The following example shows how to
modify code that uses the Clipboard object:

' Visual Basic 6.0
Clipboard.Clear
Clipboard.SetText "hello", vbCFText

If Clipboard.GetFormat(vbCFText) Then
    Text1.Text = Clipboard.GetText(vbCFText)
End If


This can be rewritten as:

' Visual Basic .NET
Dim datobj As New System.Windows.Forms.DataObject

datobj.SetData System.Windows.Forms.DataFormats.Text, "hello"
System.Windows.Forms.Clipboard.SetDataObject datobj

If System.Windows.Forms.Clipboard.GetDataObject.GetDataPresent( _
    System.Windows.Forms.DataFormats.Text) Then
    Text1.Text = System.Windows.Forms.Clipboard.GetDataObject.GetData( _
    System.Windows.Forms.DataFormats.Text)
End If

Best Regards,

HKSHK
Author
10 Nov 2006 2:58 PM
Newbie
Thank you for your reply, but all that does it get data from the clipboard,
but it doesn't actually delete (destroy all data on the clipboard) in VB.NET
2003

Any ideas?


Show quoteHide quote
"HKSHK" <hk***@gmx.net> wrote in message
news:45548e37$0$20020$9b622d9e@news.freenet.de...
> Dear Newbie,
>
> from the VB.NET 2003 online help:
>
> Clipboard Object Changes in Visual Basic .NET
>
> The Clipboard object in Visual Basic 6.0 has no direct equivalent in
> Visual Basic .NET. Although there is no direct mapping, the
> functionality of the Clipboard object can be duplicated using the
> System.Windows.Forms.Clipboard namespace.
>
> During upgrade, any code that references the Clipboard object is not
> upgraded and must be rewritten. The following example shows how to
> modify code that uses the Clipboard object:
>
> ' Visual Basic 6.0
> Clipboard.Clear
> Clipboard.SetText "hello", vbCFText
>
> If Clipboard.GetFormat(vbCFText) Then
>     Text1.Text = Clipboard.GetText(vbCFText)
> End If
>
>
> This can be rewritten as:
>
> ' Visual Basic .NET
> Dim datobj As New System.Windows.Forms.DataObject
>
> datobj.SetData System.Windows.Forms.DataFormats.Text, "hello"
> System.Windows.Forms.Clipboard.SetDataObject datobj
>
> If System.Windows.Forms.Clipboard.GetDataObject.GetDataPresent( _
>     System.Windows.Forms.DataFormats.Text) Then
>     Text1.Text = System.Windows.Forms.Clipboard.GetDataObject.GetData( _
>     System.Windows.Forms.DataFormats.Text)
> End If
>
> Best Regards,
>
> HKSHK
Author
10 Nov 2006 4:11 PM
HKSHK
Dear Newbie,

you can make some API calls:
Private Declare Function OpenClipboard Lib "user32.dll" (ByVal hwnd As
Int32) As Int32

Private Declare Function EmptyClipboard Lib "user32.dll" () As Int32

Private Declare Function CloseClipboard Lib "user32.dll" () As Int32

Then ...

OpenClipboard(0)
EmptyClipboard()
CloseClipboard()

Best Regards,

HKSHK

Newbie wrote:
Show quoteHide quote
> Thank you for your reply, but all that does it get data from the clipboard,
> but it doesn't actually delete (destroy all data on the clipboard) in VB.NET
> 2003
>
> Any ideas?
>
>
> "HKSHK" <hk***@gmx.net> wrote in message
> news:45548e37$0$20020$9b622d9e@news.freenet.de...
>> Dear Newbie,
>>
>> from the VB.NET 2003 online help:
>>
>> Clipboard Object Changes in Visual Basic .NET
>>
>> The Clipboard object in Visual Basic 6.0 has no direct equivalent in
>> Visual Basic .NET. Although there is no direct mapping, the
>> functionality of the Clipboard object can be duplicated using the
>> System.Windows.Forms.Clipboard namespace.
>>
>> During upgrade, any code that references the Clipboard object is not
>> upgraded and must be rewritten. The following example shows how to
>> modify code that uses the Clipboard object:
>>
>> ' Visual Basic 6.0
>> Clipboard.Clear
>> Clipboard.SetText "hello", vbCFText
>>
>> If Clipboard.GetFormat(vbCFText) Then
>>     Text1.Text = Clipboard.GetText(vbCFText)
>> End If
>>
>>
>> This can be rewritten as:
>>
>> ' Visual Basic .NET
>> Dim datobj As New System.Windows.Forms.DataObject
>>
>> datobj.SetData System.Windows.Forms.DataFormats.Text, "hello"
>> System.Windows.Forms.Clipboard.SetDataObject datobj
>>
>> If System.Windows.Forms.Clipboard.GetDataObject.GetDataPresent( _
>>     System.Windows.Forms.DataFormats.Text) Then
>>     Text1.Text = System.Windows.Forms.Clipboard.GetDataObject.GetData( _
>>     System.Windows.Forms.DataFormats.Text)
>> End If
>>
>> Best Regards,
>>
>> HKSHK
>
>
Author
10 Nov 2006 11:57 PM
Herfried K. Wagner [MVP]
"HKSHK" <hk***@gmx.net> schrieb:
> you can make some API calls:
> Private Declare Function OpenClipboard Lib "user32.dll" (ByVal hwnd As
> Int32) As Int32

Note that handles should be typed as 'IntPtr' in order to ensure
64-bit-Windows compatibility.

--
M S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
V B   <URL:http://dotnet.mvps.org/dotnet/faqs/>
Author
10 Nov 2006 3:21 PM
Peter Macej
> Clipboard.Clear

Clipboard.Clear method was introduced in .NET 2.0 (VS 2005), it is not
available in .NET 1.1 used in VS .NET 2003.

It seems that you need to use API call, see http://tinyurl.com/yn4nvu

--
Peter Macej
Helixoft - http://www.helixoft.com
VSdocman - Commenter and generator of class documentation for C#, VB
..NET and ASP .NET code