I'm implementing my own, custom, internationalized text editor.
I'm trying to implement copy/paste right now. Which cause me some trouble.
I'm using .NET 2.0 beta 2 (I have ordered and I'm waiting for VS Standart
edition to upgrade).
Basically I have some simple code like that:
===============
public void SelectionCopy()
{
Document doc = GetSelection();
IDataObject ido = new DataObject();
ido.SetData(DataFormats.Text, doc.ToString());
ido.SetData(Document.DataFormat_1_0, doc);
Clipboard.SetDataObject(ido);
}
public void SelectionPaste()
{
IDataObject ido = Clipboard.GetDataObject();
if (ido.GetDataPresent(Document.DataFormat_1_0))
ReplaceSelection((Document)ido.GetData(Document.Da taFormat_1_0));
else if(ido.GetDataPresent(DataFormats.Text))
ReplaceSelection((string)ido.GetData(DataFormats.T ext));
}
===============
If I copy from my text editor and paste in Notepad it works fine (most of
the time).
However if I copy from my TextEditor to my TextEditor I get and exception
like that:
the debugger catch multiple exception like below deep in the method I'm
calling
=========
System.Runtime.InteropServices.COMException was unhandled
Message="Error HRESULT E_FAIL has been returned from a call to a COM
component."
Source="mscorlib"
ErrorCode=-2147467259
StackTrace:
at
System.Runtime.InteropServices.Marshal.ThrowExcept ionForHRInternal(Int32
errorCode, IntPtr errorInfo
at System.Windows.Forms.DataObject.GetDataIntoOleStru cts(FORMATETC&
formatetc, STGMEDIUM& medium)
at
System.Windows.Forms.DataObject.System.Runtime.Int eropServices.ComTypes.IDataObject.GetDataHere(FORM ATETC&
formatetc, STGMEDIUM& medium)
at
System.Windows.Forms.DataObject.System.Runtime.Int eropServices.ComTypes.IDataObject.GetData(FORMATET C&
formatetc, STGMEDIUM& medium)
=======
but they are all catched and finally
ido.GetData(Document.DataFormat_1_0)
return me a null value (instead of the expected document).
Any tip? clue? advice? 1 2350
well, it's a problem with beta 2.
Looks like fixed in the final release..
"Lloyd Dupont" <net.galador@ld> wrote in message
news:uo**************@TK2MSFTNGP09.phx.gbl... I'm implementing my own, custom, internationalized text editor. I'm trying to implement copy/paste right now. Which cause me some trouble. I'm using .NET 2.0 beta 2 (I have ordered and I'm waiting for VS Standart edition to upgrade).
Basically I have some simple code like that: =============== public void SelectionCopy() { Document doc = GetSelection(); IDataObject ido = new DataObject(); ido.SetData(DataFormats.Text, doc.ToString()); ido.SetData(Document.DataFormat_1_0, doc); Clipboard.SetDataObject(ido); } public void SelectionPaste() { IDataObject ido = Clipboard.GetDataObject(); if (ido.GetDataPresent(Document.DataFormat_1_0)) ReplaceSelection((Document)ido.GetData(Document.Da taFormat_1_0)); else if(ido.GetDataPresent(DataFormats.Text)) ReplaceSelection((string)ido.GetData(DataFormats.T ext)); } ===============
If I copy from my text editor and paste in Notepad it works fine (most of the time). However if I copy from my TextEditor to my TextEditor I get and exception like that: the debugger catch multiple exception like below deep in the method I'm calling ========= System.Runtime.InteropServices.COMException was unhandled Message="Error HRESULT E_FAIL has been returned from a call to a COM component." Source="mscorlib" ErrorCode=-2147467259 StackTrace: at System.Runtime.InteropServices.Marshal.ThrowExcept ionForHRInternal(Int32 errorCode, IntPtr errorInfo at System.Windows.Forms.DataObject.GetDataIntoOleStru cts(FORMATETC& formatetc, STGMEDIUM& medium) at System.Windows.Forms.DataObject.System.Runtime.Int eropServices.ComTypes.IDataObject.GetDataHere(FORM ATETC& formatetc, STGMEDIUM& medium) at System.Windows.Forms.DataObject.System.Runtime.Int eropServices.ComTypes.IDataObject.GetData(FORMATET C& formatetc, STGMEDIUM& medium) ======= but they are all catched and finally ido.GetData(Document.DataFormat_1_0) return me a null value (instead of the expected document).
Any tip? clue? advice? This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Legendary Pansy |
last post by:
I was checking out the 101 C# Samples, specifically Windows Forms - Use the Clipboard. I took a look at the code for a while, and I understand what the program is doing with the cut, copy, pasting...
|
by: Rachel Suddeth |
last post by:
This may not be the right forum, but it's a problem I chiefly come across
when trying to post here.
When I do a copy/paste from VS, the text always looks really weird (and even
if I'm in an...
|
by: Max81 |
last post by:
Im trying to build a calculator for an assignment! (due wednesday)
im having trouble finding any code for creating Copy/Paste menu
buttons (just need the "doing" code)
can anyone help?
in...
|
by: lgbjr |
last post by:
Hello All,
I¡¯m using a context menu associated with some pictureboxes to provide
copy/paste functionality. Copying the image to the clipboard was easy. But
pasting an image from the clipboard...
|
by: Kaur |
last post by:
Hi, I have been successful copying a vba code from one of your posts on
how to copy and paste a record by declaring the desired fields that
needs to be copied in form's declaration and creating two...
|
by: emma.sax |
last post by:
Hi all,
I have a form where we would like the user to input their email address
twice, to ensure they've typed it correctly, as is found on most
sign-ups
I'm looking for a solution to the...
|
by: squirrelonfire |
last post by:
Hi I run postgreSQL from a remote server like this
SSH -X cnguyen_db@okaram.spsu.edu
....enter the password
Then I run bluefish& and psql
The problem I'm having is that I can't copy and paste...
|
by: Steve |
last post by:
I'm trying to code cut, copy, and paste in vb 2005 so that when the user
clicks on a toolbar button, the cut/copy/paste will work with whatever
textbox the cursor is current located in (I have...
|
by: phill86 |
last post by:
Hi I have a main form that holds records for scheduled meetings, date time location etc... in that form i have a sub form that has a list of equipment resources that you can assign to the meeting in...
|
by: jh |
last post by:
I'd like to copy/paste into a listbox during runtime. I can do this for a
textbox but can't figure out how to accomplish this for a listbox. Any
help? Thanks.
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
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,...
|
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...
|
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,...
|
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...
|
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,...
| |