-
February 1st, 2012, 08:53 AM
#1
Clipboard opening failed - C# / WPF
I am having a problem regarding clipboard and I get this error message every time I try to make a copy / paste operation from an Excel file.
The code breaks at Clipboard.GetDataObject() and the message error is this:
OpenClipboard Failed (Exception from HRESULT: 0x800401D0 (CLIPBRD_E_CANT_OPEN))
My WPF application is already running when I open Excel, write some text and then try to copy / paste.
The code that I'm using is this:
private void SetClipboardData() {
IDataObject data = Clipboard.GetDataObject();
IList result = GetDataForFileDropFormat( data );
if ( ( result != null ) && ( result.Count > 0 ) ) {
this._elementsClipboard = result;
this._sourceDrag = null;
this._sourceClipboard = null;
}
}
The above function is called in this handler method:
public void Handle_WM_DRAWCLIPBOARD( IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled ) {
SendMessage( this._nextClipboardViewer, msg, wParam, lParam );
// get data from clipboard
SetClipboardData();
handled = true;
}
I have been searching MSDN and .NET forums, but didn't find a workaround for this issue.
Could someone help me with that or give me an idea of what should I try?
Thanks!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|