Tags: allowstransparency, allowstransparencytrue, become, controls, form, invisible, microsoft, msdn, obviously, opacity, software, studio, transparent, visual, win32, windowsformshost
WindowsFormsHost and AllowsTransparency makes all win32 controls transparent
On Microsoft » Microsoft Visual Studio
8,699 words with 8 Comments; publish: Sat, 22 Dec 2007 15:30:00 GMT; (300111.33, « »)
If I set AllowsTransparency=True on a form, all of my WindowsFormsHost controls become invisible. These controls obviously don't have an opacity property, it there anything I can do to get these controls visible ?
(June CTP)
Mark
http://visual-studio.itags.org/q_visual-studio_113392.html
All Comments
Leave a comment...
- 8 Comments

Hey Mark, I also stuck with same problem :(
Do you get any idea to solve the problem
Cheers,
A. Kahn
#1; Thu, 30 Aug 2007 09:08:00 GMT

Per-pixel opacity is an entirely different painting model than the standard Win32 mechanism. There is no WM_PAINT anymore. Instead, the top-level window composes a bitmap and sends it to the OS to use as the visual representation of the window on screen. Child windows are not drawn into this bitmap, and so they are not shown on the screen. This is a general limitation of a WS_EX_LAYERED window when used via UpdateLayeredWindow().
You may have some luck by using a top-level window with the WS_EX_LAYERED style (instead of child windows), and then positioning the window over its location in the WPF application. Keeping the app window and this “fake” top-level aligned on the screen may be difficult.#2; Thu, 30 Aug 2007 09:09:00 GMT

Ashish,
Thanks for the answer. I'll just make do without the transparent border for the moment :)
Please consider warning users when they do this. it took me a little while to diagnose.
Thanks,
Mark
#3; Thu, 30 Aug 2007 09:10:00 GMT

Hi there
We are also experiencing this problem, and in our situation getting around this is a very critical thing. Is there a way to get around this problem? Is this going to be fixed in the next release of WinFX? We would like to know what the plans are for this particular issue.
Thank you!
Bridgette
#4; Thu, 30 Aug 2007 09:11:00 GMT

Hi there
We are also experiencing this problem, and in our situation getting around this is a very critical thing. Is there a way to get around this problem? Is this going to be fixed in the next release of WinFX? We would like to know what the plans are for this particular issue.
Thank you!
Bridgette
#5; Thu, 30 Aug 2007 09:12:00 GMT

I confirmed this with our expert, Dwayne Need and here's what he had to say:
This is a limitation of using WS_EX_LAYERED and UpdateLayeredWindow(). This form of layered windows does not support child windows. This is a Win32 limitation, not a WPF limitation. Child windows could be used with constant opacity (WS_EX_LAYERED and SetLayeredWindowAttributes) but WPF does not support that mode, as it is more restrictive (constant versus per-pixel opacity).
Anyways, there are various ways to try and work around the limitation. None are great. Limitations like these are part of the motivation for a new generation of presentation APIs such as WPF.
Possible solutions (various degrees of hackery):
1) Don’t host legacy child HWND controls. Try to find a WPF equivalent.
2) Write a WPF equivalent of the HWND control (HTML content seems to be a popular request)
3) Don’t use per-pixel alpha. Consider applying a HREGION instead.
4) Place your HWND control in a regular top-level window that has the app window as its owner. Position the control window where you want it.
5) Use a timer and call Win32’s PrintWindow (or send a WM_PRINT) to capture the HWND control to a bitmap, and display that bitmap in WPF.
6) Try to wrap the containing window in a WS_EX_COMPOSITED window and respond to WM_PAINT to capture a bitmap and display the bitmap in WPF.
7) Hook the HWND control’s window proc and respond to WM_PAINT by capturing the bitmap and displaying it in WPF
#6; Thu, 30 Aug 2007 09:13:00 GMT

Hello
I have this problem
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1073648&SiteID=1&mode=1
is it the same?
if it does can u give some code to demonstrate the solutions for those of us who have not familiar with what you written?
Thanx Itzik
Solved my problem thanx anyway
#7; Thu, 30 Aug 2007 09:14:00 GMT

Asish,
We are experiencing the same problems as others have mentioned here. We are a COTS vendor and we use an Active-X control which runs opengl. We run pretty much realtime with a refresh delta of about once every tenth of a second. None of the solutions you have mentioned seem viable in our situation. Are there any plans for changing the way the WindowsFormsHost element works or any other solutions in the works for this problem? This is a setback for us updating our exisiting application over to WPF.
Thanks,
-Joe
#8; Thu, 30 Aug 2007 09:15:00 GMT