/egilh

Learning by doing

Using the clipboard from .NET CF

Posted on Monday, October 04, 2004 10:26 AM

I was about to implement my own clipboard classes for .NET CF when I found the Clipboard usage article.

It has complete source code that implements the two alternatives for working with the clipboard in .NET CF.

Alternative 1: use P/Invoke to call the following methods:
[DllImport("Coredll.dll")] private static extern bool OpenClipboard(IntPtr hWndNewOwner);
[DllImport("Coredll.dll")] private static extern bool CloseClipboard();
[DllImport("Coredll.dll")] private static extern bool EmptyClipboard();
[DllImport("Coredll.dll")] private static extern bool IsClipboardFormatAvailable(uint uFormat);
[DllImport("Coredll.dll")] private static extern IntPtr GetClipboardData(uint uFormat);
[DllImport("Coredll.dll")] private static extern IntPtr SetClipboardData(uint uFormat, IntPtr hMem);

Alternative 2: use the keyboard shortcuts
So far I manually work around the missing clipboard support in .NET CF by switching to the Keyboard instead of the "Block Recognizer" when I have to cut and paste. The Windows shortcuts for cut and paste works like a charm;
Ctrl + X: Cut
Ctrl + C: Copy
Ctrl + V: Paste

The textbox example adds a popup menu to a text field and simulates the user pressing keys buy using the keybd_event API.




Feel free to drop a few cents in the tip jar if this post saved you time and money

Feedback

# Feature requests for .NET Compact Framework

1/13/2005 11:40 PM by /egilh




# .NET CF Clipboard support and SP3

3/2/2005 4:59 PM by /egilh




Post Comment
Title
 

Name
 

Url

Protected by Clearscreen.SharpHIPEnter the code you see:
Comment