473,732 Members | 2,219 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 3891
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
7476
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
1309
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
7064
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
6381
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
7899
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
4302
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
906
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
1734
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
8946
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8774
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
9447
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
9307
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...
0
9181
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8186
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6735
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
4809
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3261
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.