This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.
NativeClipboard
Pushing text to the Clipboard
One function I often need is one that will push text onto the clipboard in multiple formats. There are few ways to do that with this class:
// This function will push text in Unicode, Html, RTF (optional) and will set the Locale value to the current culture.using(varcb=newNativeClipboard())cb.SetText(@"“We’ve been here”","<span style=\"color:#dcdcaa;\">“We’ve been here”</span>",null/* Could be RTF text */);// Optionally, you can push a single text formatusing(varcb=newNativeClipboard())cb.SetText(@"“We’ve been here”",TextDataFormat.UnicodeText);
Pushing binary data to the Clipboard
// Get a custom id or use one of the exitingvarfmtId=DataFormats.GetFormat("MyBinData").Id;// At the heart of all things is just pushing a byte streamusing(varcb=newNativeClipboard())cb.SetBinaryData(fmtId,newbyte[]{12,24,48,96,8,16,32,64,128});// Or, push a blittable structureusing(varcb=newNativeClipboard())cb.SetData(fmtId,newRECT(0,0,10,100));// Or, push an array of blittable structuresusing(varcb=newNativeClipboard())cb.SetData(fmtId,new[]{newRECT(0,0,10,100),newRECT(1,1,5,10),newRECT(2,2,15,20)});
Getting list of all available formats on the clipboard
using(varcb=newNativeClipboard()){if(cb.EnumAvailableFormats().Any(f=>f.Name==DataFormats.Dib)){// Do something}}// Or, look at just a single oneusing(varcb=newNativeClipboard())Console.WriteLine($"Dib avail? {cs.IsFormatAvailable(DataFormats.Dib)}");
Delete Page
Deleting the wiki page "Vanara.Windows.Shell.NativeClipboard" cannot be undone. Continue?