WordPress database error: [INSERT, UPDATE command denied to user '51213-2'@'10.10.20.185' for table 'wp_options']INSERT INTO `wp_options` (`option_name`, `option_value`, `autoload`) VALUES ('_transient_doing_cron', '1714222064.8383710384368896484375', 'yes') ON DUPLICATE KEY UPDATE `option_name` = VALUES(`option_name`), `option_value` = VALUES(`option_value`), `autoload` = VALUES(`autoload`)
<\/a>Integrating win 32 component is already possible in WPF 4.0, even in WPF 3.5 but there is the well-know issue : airspace problems<\/a>. Each render technology belongs to only one airspace only. So when you place Win32 components in your WPF application they behave as black hole for input, render transformation are not (well) applied, etc.<\/p>\n With this 4.5 release, the WPF team solves this drawback. In this post more explanation and an example of how it improves developers’ life will be gived.<\/p>\n This post is a part of a serie on WPF 4.5 new features<\/a>.<\/p>\n <\/p>\n I’ll only write about the integration of Winform\/Win32 controls into WPF because this is the only subject I know wel. This is really annoying when you are used to WPF and this is why hosting a Win32 control into a WPF 4.0 apps is rarely done.<\/strong><\/p>\n There is two main properties which are new in WPF 4.5 and related to this feature on the HwndHost class: IsRedirected <\/a>and CompositionMode<\/a>.<\/p>\n IsRedirected is a boolean which can be understand as : “do we solve airspace issue<\/strong> and share the screen between Win32 controls and WPF? You may wonder as I am why this is not set to true by default. I have the opinion that enabling it can lead to performance issues and is something you have to do only if needed.<\/p>\n CompositionMode is an enumeration which tells how deep the integration has to be done <\/strong>:<\/p>\n This two properties have to be set before any rendering is done otherwise an exception will be thrown.<\/strong><\/p>\n You may know that the WPF WebBrowser is in fact the Win32 one disguised as a WPF control. It means that every drawbacks that we have seen before are present when you use it on a application.<\/p>\n With WPF 4.5 you can now use it as if it is a standard control. All you have to do is to set the two properties we’ve seen before to the correct values.<\/p>\n So let’s say that I want to display a WebBrowser with an opacity of 0.6 and that I want it to be scaled to the half of it size. Because I am evil, I also want to display a VisualBrus of it inside a Rectangle just next to it. The XAML meeting these requirements will then be : Then to make it works, I have to activate the redirecting and to set the composition mode of the WebBrowser internal HwndHost. The WPF team thought at this usage and you can find the same property on it. I do it in the Window constructor to be sure that no rendering has be done: _webBrowser.CompositionMode = System.Windows.Interop.CompositionMode.Full; That’s all. Here is a comparison of the rendering in WPF 4.0 and 4.5:What can’t be done in WPF4.0<\/h3>\n
\nBefore WPF 4.5, if you add a Win32 component into a wpf application using the hwndhost control you have some limitations:<\/p>\n\n
What’s new in WPF 4.5 ?<\/h3>\n
\n
An example with the WebBrowser control<\/h3>\n
\n[xml]<UniformGrid Columns="2" x:Name="grid">
\n <WebBrowser x:Name="_webBrowser" Source="http:\/\/www.jonathanAntoine.com"
\n Margin="5" Opacity="0.6">
\n <WebBrowser.RenderTransform>
\n <ScaleTransform ScaleX="0.5" ScaleY="0.5" \/>
\n <\/WebBrowser.RenderTransform>
\n <\/WebBrowser>
\n <Rectangle Margin="5">
\n <Rectangle.Fill>
\n <VisualBrush Visual="{Binding ElementName=_webBrowser}" \/>
\n <\/Rectangle.Fill>
\n <\/Rectangle>
\n<\/UniformGrid>
\n[\/xml]<\/p>\n
\n[csharp]public MainWindow()
\n{
\n InitializeComponent();<\/p>\n
\n _webBrowser.IsRedirected = true;
\n}
\n[\/csharp]<\/p>\n
\n<\/a><\/p>\n