473,698 Members | 2,145 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Custom format on Clipboard

I am trying to Copy and paste using a custom format but I canot retrieve the
data.
In the main Form's class I have declared:

Dim myDocmanFormat as DataFormats.For mat

then in the New Sub of the main form I have:

myDocmanFormat = DataFormats.Get Format("DocmanF ormat")

In the Copy sub I have:

Dim thisDataObject As New DataObject
Dim thisData As DocmanData = CType(thisNode. Tag, DocmanData).Clo ne
thisDataObject. SetData(Me.myDo cmanFormat.Name , thisData)
Clipboard.SetDa taObject(thisDa taObject, True)

When I step through this part of the Copy routine "thisData" is definately
not Nothing. In the watch window I can access all of the properties of
"thisData".
In the Paste routine I have:

If Clipboard.GetDa taObject.GetDat aPresent(Me.myD ocmanFormat.Nam e) Then
Dim myClipData As IDataObject = Clipboard.GetDa taObject()
Dim DataFromClip As DocmanData =
CType(myClipDat a.GetData(Me.my DocmanFormat.Na me), DocmanData)

Although the data format is present it always returns Nothing, that is
"DataFromCl ip" remains Nothing after executing the last line.

Can someone please tell me what I have done wrong.

Thanks,
Fred
Nov 20 '05 #1
2 3883
Hi Fred,

I don't see anything obviously wrong. You need to make sure the class
DocmanData is serializable. Here's some sample test code I threw together
that seems to work.

<Serializable() > _
Public Class TestObject

Private m_Value As String

Public Sub New(ByVal testValue As String)
m_Value = testValue
End Sub
Public Property TestValue() As String
Get
Return m_Value
End Get
Set(ByVal Value As String)
m_Value = Value
End Set
End Property
End Class

Public Class Form1
Inherits System.Windows. Forms.Form

#Region " Windows Form Designer generated code "
Private Sub buttonCopy_Clic k(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles buttonCopy.Clic k
Dim test As New TestObject("Hel lo, this is a test.")
Dim testFormat As DataFormats.For mat =
DataFormats.Get Format("MyTestF ormat")
Dim dataObj As New DataObject
dataObj.SetData (testFormat.Nam e, False, test)
Clipboard.SetDa taObject(dataOb j)
End Sub

Private Sub buttonShow_Clic k(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles buttonShow.Clic k
Dim dataObj As DataObject = Clipboard.GetDa taObject()
Dim testFormat As DataFormats.For mat =
DataFormats.Get Format("MyTestF ormat")
If dataObj.GetData Present(testFor mat.Name, False) Then
Dim test As TestObject =
CType(dataObj.G etData(testForm at.Name), TestObject)
MsgBox(test.Tes tValue)
Else
MsgBox("No data present")
End If
End Sub
End Class

Perhaps you can use this to see what's different in your case.

Craig VB.Net Team
--------------------------------------------------------------------
This reply is provided AS IS, without warranty (express or implied).

--------------------
From: "fred" <fr**@NoSpam.co m>
Subject: Custom format on Clipboard
Date: Mon, 12 Apr 2004 21:56:09 +1200
Lines: 36
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
Message-ID: <#i************ **@TK2MSFTNGP11 .phx.gbl>
Newsgroups: microsoft.publi c.dotnet.langua ges.vb
NNTP-Posting-Host: 219-88-118-13.dialup.xtra. co.nz 219.88.118.13
Path: cpmsftngxa06.ph x.gbl!TK2MSFTNG XA06.phx.gbl!TK 2MSFTNGXA05.phx .gbl!TK2MSFTNGP 0
8.phx.gbl!TK2MS FTNGP11.phx.gblXref: cpmsftngxa06.ph x.gbl microsoft.publi c.dotnet.langua ges.vb:194669
X-Tomcat-NG: microsoft.publi c.dotnet.langua ges.vb

I am trying to Copy and paste using a custom format but I canot retrieve thedata.
In the main Form's class I have declared:

Dim myDocmanFormat as DataFormats.For mat

then in the New Sub of the main form I have:

myDocmanFormat = DataFormats.Get Format("DocmanF ormat")

In the Copy sub I have:

Dim thisDataObject As New DataObject
Dim thisData As DocmanData = CType(thisNode. Tag, DocmanData).Clo ne
thisDataObject. SetData(Me.myDo cmanFormat.Name , thisData)
Clipboard.SetDa taObject(thisDa taObject, True)

When I step through this part of the Copy routine "thisData" is definately
not Nothing. In the watch window I can access all of the properties of
"thisData".
In the Paste routine I have:

If Clipboard.GetDa taObject.GetDat aPresent(Me.myD ocmanFormat.Nam e) Then
Dim myClipData As IDataObject = Clipboard.GetDa taObject()
Dim DataFromClip As DocmanData =
CType(myClipDa ta.GetData(Me.m yDocmanFormat.N ame), DocmanData)

Although the data format is present it always returns Nothing, that is
"DataFromCli p" remains Nothing after executing the last line.

Can someone please tell me what I have done wrong.

Thanks,
Fred



Nov 20 '05 #2
Thanks Craig, the <Serializable() > attribute seems to have fixed the
problem.

Fred

"Craig Vick [MSFT]" <cr*****@online .microsoft.com> wrote in message
news:6y******** ******@cpmsftng xa10.phx.gbl...
Hi Fred,

I don't see anything obviously wrong. You need to make sure the class
DocmanData is serializable. Here's some sample test code I threw together
that seems to work.

<Serializable() > _
Public Class TestObject

Private m_Value As String

Public Sub New(ByVal testValue As String)
m_Value = testValue
End Sub
Public Property TestValue() As String
Get
Return m_Value
End Get
Set(ByVal Value As String)
m_Value = Value
End Set
End Property
End Class

Public Class Form1
Inherits System.Windows. Forms.Form

#Region " Windows Form Designer generated code "
Private Sub buttonCopy_Clic k(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles buttonCopy.Clic k
Dim test As New TestObject("Hel lo, this is a test.")
Dim testFormat As DataFormats.For mat =
DataFormats.Get Format("MyTestF ormat")
Dim dataObj As New DataObject
dataObj.SetData (testFormat.Nam e, False, test)
Clipboard.SetDa taObject(dataOb j)
End Sub

Private Sub buttonShow_Clic k(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles buttonShow.Clic k
Dim dataObj As DataObject = Clipboard.GetDa taObject()
Dim testFormat As DataFormats.For mat =
DataFormats.Get Format("MyTestF ormat")
If dataObj.GetData Present(testFor mat.Name, False) Then
Dim test As TestObject =
CType(dataObj.G etData(testForm at.Name), TestObject)
MsgBox(test.Tes tValue)
Else
MsgBox("No data present")
End If
End Sub
End Class

Perhaps you can use this to see what's different in your case.

Craig VB.Net Team
--------------------------------------------------------------------
This reply is provided AS IS, without warranty (express or implied).

--------------------
From: "fred" <fr**@NoSpam.co m>
Subject: Custom format on Clipboard
Date: Mon, 12 Apr 2004 21:56:09 +1200
Lines: 36
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
Message-ID: <#i************ **@TK2MSFTNGP11 .phx.gbl>
Newsgroups: microsoft.publi c.dotnet.langua ges.vb
NNTP-Posting-Host: 219-88-118-13.dialup.xtra. co.nz 219.88.118.13
Path:

cpmsftngxa06.ph x.gbl!TK2MSFTNG XA06.phx.gbl!TK 2MSFTNGXA05.phx .gbl!TK2MSFTNGP 0 8.phx.gbl!TK2MS FTNGP11.phx.gbl
Xref: cpmsftngxa06.ph x.gbl microsoft.publi c.dotnet.langua ges.vb:194669
X-Tomcat-NG: microsoft.publi c.dotnet.langua ges.vb

I am trying to Copy and paste using a custom format but I canot retrieve

the
data.
In the main Form's class I have declared:

Dim myDocmanFormat as DataFormats.For mat

then in the New Sub of the main form I have:

myDocmanFormat = DataFormats.Get Format("DocmanF ormat")

In the Copy sub I have:

Dim thisDataObject As New DataObject
Dim thisData As DocmanData = CType(thisNode. Tag, DocmanData).Clo ne
thisDataObject. SetData(Me.myDo cmanFormat.Name , thisData)
Clipboard.SetDa taObject(thisDa taObject, True)

When I step through this part of the Copy routine "thisData" is definatelynot Nothing. In the watch window I can access all of the properties of
"thisData".
In the Paste routine I have:

If Clipboard.GetDa taObject.GetDat aPresent(Me.myD ocmanFormat.Nam e) Then Dim myClipData As IDataObject = Clipboard.GetDa taObject()
Dim DataFromClip As DocmanData =
CType(myClipDa ta.GetData(Me.m yDocmanFormat.N ame), DocmanData)

Although the data format is present it always returns Nothing, that is
"DataFromCli p" remains Nothing after executing the last line.

Can someone please tell me what I have done wrong.

Thanks,
Fred


Nov 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
7467
by: BC | last post by:
Hello, We are creating an Office add-in. We are able to display the add-in successfully. However, we followed a sample program, and it displays a FaceID = 1044 (which is not the bitmap of the button we want to display). We want to display our own custom bitmap. How do we display our own custom bitmap instead of the bitmap associated with FaceID = 1044?
0
1308
by: MacDk | last post by:
Hi, I need to paste some text to users clipboard from an ASP.NET-page. This can be done by DHTML, but the trick is that the text must by pasted as HTML not pure text. Cant figure out how to do this. The clipboard data will be pasted into word (with format) by clients. Can anyone point me in the right direction?
0
191
by: fred | last post by:
I am trying to Copy and paste using a custom format but I canot retrieve the data. In the main Form's class I have declared: Dim myDocmanFormat as DataFormats.Format then in the New Sub of the main form I have: myDocmanFormat = DataFormats.GetFormat("DocmanFormat")
11
7060
by: nAmYzArC | last post by:
Hi all, On our site we have a section that allows users to copy and paste or drag and drop the contents of (pretty much any) webpage into a Div. I need to get access to the clipboard data. To do this I'm using the ..getData() function. Problem is, I only have access to 'Text' and 'URL' formats. I'd like to have an HTML format. The reason for this is that I'd like to do some text replacements in the clipboard before the contents are...
7
6378
PEB
by: PEB | last post by:
Hi, I've managed to copy an image to the clipboard from other application different from Access, but i want to get the image in the clipboard and save it in tif format using Access... Somewhere i've found a function that loads the image in an Ole field. Is it necessary to do this before saving the image in tif? Thanks Vlady
6
7896
dima69
by: dima69 | last post by:
Biff format is defined as default format for copying data from Access to Excel (under registry key ...\Access\Clipboard Formats). This format has a known problem as numbers are pasted as text using Access 2002 with Excel 2002. So M$ suggest using older Biff5 format (from Office 2000) instead of Biff8. But Biff5 has a problem too. Numbers from fields with input mask set are pasted in Excel as text, if you copy the record (not one field). On the...
1
4297
by: chris | last post by:
I'm not sure this is even feasible. What I want to do is create a command button. When this command button is pressed, it taes field values and puts them into text format. I think I know how to do this part thru code. Then I want to copy this text to the clipboard so that I can paste it into a memo field. This is the part I need help with. I will create the text by the following method on the On Click Event of the command button:
0
903
by: pnarasimha | last post by:
Hai Friends , I have strucked with one problem in my Project , that is actually in my Project i had Grid control and User may Copy excel data from Excel file rows and paste into in that Grid Control so for that iam able Getting that Data Based on "Commaseparated"and "Tex" and As well "Stringformat" so here im using "Commaseperated" and iam putting that Data into "Streamreader" and splitting that based on the Commaseperated...
1
1731
by: =?Utf-8?B?UmljaA==?= | last post by:
Hello, I created a basic class library (dll, tlb) in VB2005 for com use in MS Access. I added a form to the class library because eventually, I want to use a SaveDialog control with this dll. I compiled the class to be com visible and register for com (in the compile tab). The build went successfully, and I can invoke the class from an MS Access code module. Upon invoking the dll, you can see the dll form for a split second, then...
0
8608
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9164
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9029
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8898
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6524
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4370
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4619
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2332
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2006
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.