ElementHost repainting - c#

I'm using AvalonEdit in my WinForms application. AvalonEdit is placed onto control with ElementHost on it. Application has RadDock from Telerik and AvalonEdit can be placed on its windows. Often I get problem with ElementHost repainting. I don't know all the symptoms, but I can reproduce this problem by changing focus and moving other windows over the editor. After this all WPF controls in my application become broken and can't be repainted. The only way to force to redraw ElementHost is resizing. I can change for example width and WPF control will be redrawn. But this "solution" is not acceptable. The problem can be reproduced for docked or floating windows, for windows with active scrollbars or without, on x64 and x86 machine. To "fix" ElementHost I need to restart application.
Have somebody any suggestion for me?

Related

WinForms in Mono - Problems with form repainting

I have a WinForms Application. I need it to run also in Mono.
I have a problem with form repainting. There are many controls in the form. When I resize the form or when I try to update it (it needs to be updated on timer tick), the repainting does not work . Sometimes the controls are placed right, but it flickers, sometimes the the controls do not move or resize at all, some of the controls (buttons) seem to be disabled, some of them even disappear or are displayed twice.
In .NET I had similar problems, but enabling double-buffering on form solved them. But it seems that it does not work in Mono at all and I really don't know what to do.
On resize I need to move and resize the controls and redraw pictures in PictureBoxes.
I also have a problem with the above mentioned timer - the tick event fires only once and then almost everything on the form stops working, but I think it may be connected with the repainting problem.
If someone had an advice on how to correctly repaint a WinForms form in Mono, I would appreciate it.

Can I make WebBrowser translucent and borderless in WPF?

I am finding that setting the Opaque value has no effect. Also there is always a border around the WebBrowser.
From the WPF WebBrowser page on MSDN:
The WebBrowser control internally instantiates the native WebBrowser ActiveX control.
So it's not an actual WPF control... just a wrapper around a native control that allows little customization.
Here's a blog that summarizes what you can't do with the ActiveX control pretty well:
If you add a Win32 component into a wpf application using the hwndhost control you have some limitations:
Resizing is limited because only the container(hwndhost) will be resized, not the contained component itself.
Forget about rotation and skewing.
The hosted component is a black hole for your application : always at the top (forget the z-order!).
Opacity can’t be applied to an hosted Win32 control.
VisualBrush do not work with Win32 controls.
He goes on to explain a work-around that would come with WPF 4.5, but I can't find anywhere that those promised features ever shipped. They don't appear to have.
About the border.. when I test it I don't have one. But if you do, I'm guessing there's no way to remove that either.
Here's what I see in a small test project (the WebBrowser has a margin of 20px, and it's inside of a GroupBox with 20px padding):

WPF content in ElementHost not visible using DockPanel Suite

I have a WPF control in an ElementHost on a WinForms form. I've added the Form to a DockPanel Suite pane. The WPF content displays correctly when the Form is floating, or docked left/right/top/bottom, but when DockState is Document the WPF content disappears, leaving a blank docked Form.
I've experimented with creating empty test WPF controls, and this behaviour occurs whenever an ElementHost is used on a WinForm, and docked using DPS. Can anyone suggest where to look for a fix ? I've set the WPF rendering to Software only, but it doesn't help with this problem.
Many thanks.
WinForms App using .NET 4.0, VS2012 on Windows 7 on VMWare Fusion on MacBook Pro.
After much poking around, the problem turned out to be due to a ToolStripContainer that was on the same form as the DPS DockPanel. When the ElementHost form was docked as document, this was being rendered over the top of it. I replaced the ToolStripContainer with a separate ToolStrip and MenuStrip (following the DockSample), and all works fine.

How do I set form size and location synchronous

I made custom borders for my application, like the VisualStudio 2012
There is one central mainform and 4 smaller, dynamically positioned border forms.
In the mainform I have overidden the events OnMove, OnSizeChanged, OnActivate, OnDeactivate.
In those events I set the location, size and color of the borders.
It works quite nicely, but there is some awful artifacts!
Those are the same artifacts that appear when resizing ANY window.
I made a video with my application to show what kind of atrifacts I mean.
Those appear when moving or resizing the window.
Obviously this problem IS solveable, because VisualStudio2012 does it too (meaning that it doesn't have the problem. Just try it, resize the VS2012 window, it won't flicker)
In my implementation I used the same way that VS2012 uses: 4 layered windows that make up the border of the form.
In case someone doesn't the glitches I'm talking about. Here's the video:
http://youtu.be/kKiPke8ruaI
What I need is a way to "synchronously" set the location and size of the 4 border windows.

Adding Transparent backgrounds to WindowsFormsHost Controls in WPF

I'm using the WindowsFormsHost to add a Windows Forms control in my WPF application, but I realise that WinForms controls cannot have transparent backgrounds without setting the style as in here How to: Give Your Control a Transparent Background. How would this be done in WPF?
BTW, I'm using C# and .net 4.0.
Thanks.
I don't think you can do this. The link you provided is really about being able to set the BackColor to Transparent. When that happens the WinForms control (in its paint background handling) gets the Parent Control and calls its PaintBackground and Paint methods. While your control will have a parent - the control that the WindowsFormsHost will create - that control will not and so there will be nothing to draw the background. In a Win32 world one might set the WS_EX_TRANSPARENT bit but that introduces all sorts of issues and I suspect it may not even work based on how WPF works. I would check out the MSDN topics (e.g. Technology Regions Overview and WindowsFormsHost interop) discussing the various air space issues with interop between WPF and other technologies.

Categories

Resources