Windows 7 Forums

Welcome to Windows 7 Forums. Our forum is dedicated to helping you find support and solutions for any problems regarding your Windows 7 PC be it Dell, HP, Acer, Asus or a custom build. We also provide an extensive Windows 7 tutorial section that covers a wide range of tips and tricks.


Windows 7: Getting full paste (Text+Code)

23 Dec 2016   #1
RanC

Windows 7
 
 
Getting full paste (Text+Code)

In windows, you can paste regular text (like from notepad to Word), and styled text (like copying colored text from one Word to another, or even text with bullets from here (chrome) to a Word document).
I believe that when you "copy", you copy the text, along with meta-chars that are the style.
How can I see these meta-chars? Is there A C# code that can do this?


My System SpecsSystem Spec
.
23 Dec 2016   #2
Lance1

Windows 7 Ultimate, Service Pack 1, 64 bit
 
 

Are you referring to the source code of a web page? Right click the web page and select "View Page Source "
My System SpecsSystem Spec
23 Dec 2016   #3
RanC

Windows 7
 
 

Not only source code. Say I copied styled text from Word. How can I know the style?
My System SpecsSystem Spec
.

23 Dec 2016   #4
Lance1

Windows 7 Ultimate, Service Pack 1, 64 bit
 
 

If you copy styled text from one Word doc to another. Highlight the styled text in question and click the Home tab. Look under styles and that style should be highlighted. I hope this is this is what you are referring too.
My System SpecsSystem Spec
23 Dec 2016   #5
RanC

Windows 7
 
 

Quote   Quote: Originally Posted by Lance1 View Post
If you copy styled text from one Word doc to another. Highlight the styled text in question and click the Home tab. Look under styles and that style should be highlighted. I hope this is this is what you are referring too.
No. What I mean is not only in Word. If I copied a text with bullets to Word (or any other program that supports text with bullets) - text with bullets would appear. If we have a program that supports colorful text, colorful text would appear. How do I know the style? If I copied blue text from Word, how would I know *programmatically* that its blue? How do I know what meta-singes are attached (I know how to programmatically invoke adding plain text to the clipboard via C#/Java - how do I invoke copying blue text?)?
My System SpecsSystem Spec
07 Jan 2017   #6
Alejandro85

Windows 7 Ultimate x64
 
 

So this is entirely a programming question?
If so, the first thing to understand is how the clipboard really works.

The clipboard works by holding data and its associated format. Each program specifies what format it's sending data in, so the pasting software knows how to deal with it. The trick that makes the clipboard so flexible is that it allows programs to set multiple copies of the very same data, in different formats, at the same time.
When you copy a chunk of text from Word, what actually happens is that Word places the text multiple times, one in plain text, other in rich text format, some other proprietary format and so on. What this allows is to provide a wide range of options for programs to paste from. Notepad may pick the plain text, Word would pick the most complete format, another editor maybe would pick RTF, and so on.

Back to the original question, when you read data from the clipboard, you can query what data formats are available, then if the formated text is there, you can read it by specifying the appropriate format. It would contain, for example, the RTF simbols or the HTML markup, which is then up to you to interpret.

As an example, a few threads on StackOverflow deal with this. Two specially relevant are those:
winforms - C# How can I paste formatted text from clipboard to the RichTextBox - Stack Overflow
.net - Copying text along with its formatting from a RichTextBox - Stack Overflow

While both talk about a RichTextBox control, the clipboard part is independent of it and you can use it in any situation you need. Also, be sure to read something from Wikipedia:
Clipboard (computing - Wikipedia)

And finally, the official .NET Framework reference on the topic, applicable to C#, as well as all .NET languages:
Clipboard Class (System.Windows.Forms)

I have no real experience with Java, but the fundamental concepts are the same. Its documentation will help fill the gaps and understand the differences in the APIs.
My System SpecsSystem Spec
Reply

 Getting full paste (Text+Code)




Thread Tools




Similar help and support threads
Thread Forum
How to copy and paste Full Internet Path to Public Folders & Files
Hello, I would like to know how I can copy the full internet path to public folders and files in Windows 7. In Windows XP, I was able to right click a folder or file, select copy path --> copy full internet path, and then paste the result into emails / documents / etc in order to direct...
General Discussion
Can't cut and paste text from IE9 webpages
I use IE9 for the "Globe & mail" website (because I can get past their article limit with it), but I can't cut and paste with my mouse in the usual way. When I click the right mouse button, instead of the usual "copy/cut/paste/delete options, I get this: (see attachment) This only happens...
Browsers & Mail
A Quick way to paste predetermined text/numbers?
Basically I am looking for any way that will enable me to paste a predetermined string of text or numbers e.g. if i pressed F1 then that will automatically paste "hello" and F2 would paste "My Name is" etc Does anybody know of a way how this could be done? It does even have to be a hotkey, it...
General Discussion
Is there a copy-paste plug-in that can handle text & images?
Hi WSF techs, Is there a copy-paste plug-in that is compatible with Windows 7 that can handle text and images? Once, on another machine, I had a simple little copy-paste plug-in that just appeared as a tiny palette on my desktop that would handle up to 10 or so copy and paste saves for text...
Software
Select, copy and paste text from windows
Hello everyone. Sorry if this has been already discussed but the search engine didn't show any match on the matter. At least I can't select text in a window to be copied and pasted elsewhere. If my memory serves me right, it was possible with XP. I know there are windows on which a right...
General Discussion


Our Sites

Site Links

About Us

Find Us

Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

Designer Media Ltd

All times are GMT -5. The time now is 07:12.
Twitter Facebook Google+ Seven Forums iOS App Seven Forums Android App