Cannot obtain value of local or argument 'hwndSource' as it is not available at this instruction poi
Posted
by Dänu
on Stack Overflow
See other posts from Stack Overflow
or by Dänu
Published on 2010-06-13T18:57:07Z
Indexed on
2010/06/13
19:02 UTC
Read the original article
Hit count: 663
Hey Guys
I'm playing around with Interops and I thought: "Hey let's code something that accesses the clipboard ..." so I googled and found some articles (yeah I'm doing it with WPF - .Net 3.5).
However the following method generates an error (as seen in the title) and throws a stackoverflow.
private void Window_SourceInitialized(object sender, EventArgs e)
{
// Hook to Clipboard
base.OnSourceInitialized(e);
HwndSource hwndSource = PresentationSource.FromVisual(this) as HwndSource;
if (hwndSource != null)
{
installedHandle = hwndSource.Handle;
viewerHandle = SetClipboardViewer(installedHandle);
hwndSource.AddHook(new HwndSourceHook(this.hwndSourceHook));
}
// End Hook to Clipboard
}
I have (really) no idea what's going on there.
Any Ideas?
© Stack Overflow or respective owner