Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > Avalon

Vista - Crazy question - is there any way to extract the display of a windowinto an image file?

 
 
Old 01-10-2006   #1 (permalink)
Jason Dolinger


 
 

Crazy question - is there any way to extract the display of a windowinto an image file?

Just like the subject says. I've got this idea for extracting an image
(.bmp, .jpg, .pnf, whatever) that looks like the display of a window and
putting it at the content of a WPF button. Does anyone know of a
possible way to do that? I was hoping I could actually nest the window
directly as the button content, but that ends up with the following
runtime exception:

{"Window must be the root of the tree. Cannot add window as a Logical or
Visual child of any Visual."}


Thanks!
Jason

My System SpecsSystem Spec
Old 01-10-2006   #2 (permalink)
Douglas Stockwell


 
 

Re: Crazy question - is there any way to extract the display of a window into an image file?

I think you are looking for VisualBrush. Unfortunately, if you try to reference
a visual earlier in the tree you end up in an infinite loop. It doesn't look
like you will be able to use this to get an image of the entire window. Depending
on your exact scenario this simple example may help:

<Window x:Class="WindowsApplication.Window1"
xmlns="http://schemas.microsoft.com/winfx/avalon/2005"
xmlns:x="http://schemas.microsoft.com/winfx/xaml/2005">
<DockPanel>
<StackPanel Name="MainWindow">
<Button>Button 1</Button>
<Button>Button 2</Button>
<Button>Button 3</Button>
</StackPanel>
<Button>
<Rectangle Width="300" Height="300">
<Rectangle.Fill>
<VisualBrush Visual="{Binding ElementName=MainWindow}" />
</Rectangle.Fill>
</Rectangle>
</Button>
</DockPanel>
</Window>

> Just like the subject says. I've got this idea for extracting an
> image (.bmp, .jpg, .pnf, whatever) that looks like the display of a
> window and putting it at the content of a WPF button. Does anyone
> know of a possible way to do that? I was hoping I could actually nest
> the window directly as the button content, but that ends up with the
> following runtime exception:
>
> {"Window must be the root of the tree. Cannot add window as a Logical
> or Visual child of any Visual."}
>
> Thanks!
> Jason



My System SpecsSystem Spec
 

Thread Tools


Similar Threads
Thread Forum
System Image - Extract Files Using Virtual PC 2007 Tutorials
Using Ildasm.exe to extract an image in a PictureBox .NET General
the display goes crazy Vista hardware & devices
funny image making my vista go crazy Vista General
HP Compaq NX7000 display goes crazy after install Vista hardware & devices


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46