how to make somthing like this
Windows Forms Glass Effect, Make ImageBox transparent
I use VS 2010
If all you are looking for is the standard glass effect (which includes the blur), check out this article:
http://www.codeproject.com/KB/vista/AeroGlassForms.aspx
Basically, all you're doing is extending the window's frame (which already has the glass effect) into the client area. You have to call the DWM API that come with Windows Vista or later using a couple of P/invoke methods because this is not built into the .NET Framework.
EDIT: If you're looking for more control over the blur effect, you might look into more specifically the DwmEnableBlurBehindWindow function from the DWM API, although I have not used this myself.
Take a look at this:
http://msdn.microsoft.com/en-us/library/aa969512(VS.85).aspx
The MARGINS array is similar to margins on an HTML page. The first example on MSDN gives the margins for the glass effect 25 pixels in height on the bottom of the window.
This MS tutorial is fairly easy to understand and uses C#.
Related
is there any way that winforms or WPF can do this kind of UI? transparent with blur window.
A forenote: Windows 8 removes the Aero Glass effect. Windows will appear with a solid background where there would be glass (like how they appear on Windows 7 when you disable the glass effect but still run the DWM).
That said, the effect is done using Win32's DwmExtendFrameIntoClientArea function. Using this in your program differs depending on whether you're using WPF or WinForms (as WPF windows do some pretty interesting window subclassing, and of course, WPF controls are largely windowless).
To get a "whole glass" window, you just use the DwmExtendFrameIntoClientArea function to fill your window, rather than just the first 50px or so, which is what IE and other browsers do.
This is the canonical MSDN article on how to do this with WPF: http://msdn.microsoft.com/en-us/library/ms748975.aspx
For WinForms, see this blog article: http://blogs.msdn.com/b/tims/archive/2006/04/18/578637.aspx
Enjoy, but not for long considering Windows 8...
In Windows.Forms, I was not able to reproduce the exact same TextBox border as you see it in Vista / 7 Aero. All I get is a gray rectangle instead the slightly sunken gray / blue 3d border. I tried the following methods with no success:
VisualStyleRenderer class
TextBoxRenderer class
Control.DrawToBitmap()
P/Invoke with UxTheme and friends
Drawing RichTextBox elements instead of TextBox ones
This problem has already been discussed here but with no solution: http://social.msdn.microsoft.com/Forums/hu-HU/winforms/thread/46e66852-b52e-420d-8fe0-b717f86ecb18
It looks like there's no obvious solution for this problem.
Does anyone know how to draw the exact same border as in Aero?
It's probably not going to happen for you.
I think the VisualStyleRenderer, including the TextBoxRenderer, were more meant for the XP themes.
Even the Control.DrawToBitmap(...) function magically draws a different version from what is on the screen.
I don't have the canonical answer for this, but it's most likely a result of Microsoft moving on with WPF and leaving behind the WinForm controls with those visual themes half-baked.
The only answer to this question is to use WPF or use a 3rd party system like DevExpress (which support custom themes) if you need to "theme" all of your controls.
I have an Image object in my application which the user can drag around. The object displays an image which is partly transparent, so the window background (which is itself a bitmap) can be seen through it.
I want to add a graphics effect to this object. Assume that I already have an algorithm for this effect — that’s not the issue. The issue is how to get this algorithm into WPF.
So I tried to look at how DropShadowEffect works, but the implementation displayed in Reflector is empty. I also tried to look at what methods from the abstract classes Effect and ShaderEffect I should override and there doesn’t seem to be anything related to actually rendering an effect.
So how do I create my own effect?
The best and fastest way is to use pixel shaders (supported starting with WPF 3.5 SP1 I think) . It will require some shader language (HLSL) knowledge, though :-)
Here is a tutorial: How Do I: Create Custom Pixel Shader Effects for WPF
a library on codeplex: Windows Presentation Foundation Pixel Shader Effects Library
an article with .NET 4 information (including Sliverlight support which has it too): SilverShader – Introduction to Silverlight and WPF Pixel Shaders
A very cool tool (and resource) is Shazzam it will help you to create the effects and it contains a nice tutorial.
Can I use that effect on my controls just like the BlurEffect? If it's not available, is there a way to "acquire" it? Perhaps via the Reflector?
Which "Aero" effect are you referring to?
You can extend the glass effects into your client area in a WPF application via DwmExtendFrameIntoClientArea.
If you're just after the blurring, you could use BlurBitmapEffect from WPF directly.
No, it is not included.
Yet, there is a Glass Effect in plain WPF that works fine on XP too. It is not the exact duplicate of Aero Glass, but looks nice.
Duplicate:
Is it possible to achieve the “Aero Glass” look on XP?
If I use Winforms and I write a win32 application with it, I can see the Aero glass effects in Vista but not in XP.
How could I achieve the same look across different platforms? I am using WPF.
As a side question, did Microsoft write the Aero glass effects using WPF? If so, shouldn't the glass effect be the default WPF look on the other platforms?
What "Aero effect" are you referring to? If you're talking about the window glass, then I'm afraid you're out of luck, as the glass effect is made possible only through Vista's Desktop Window Manager.
If you're simply looking for window transparency, rounded corners, etc., then this is certainly possible in XP. Check out this article for more information.
Ok, so most of the DWM stuff is handled by a DLL called dwmapi.dll, it is all in C++ COM because that is how Microsoft writes it's APIs, you may have noticed that to call the methods in the API you have to use some unmarshalled boolean types etc, this is because it has to reach unmanaged code, some of the operations that need to take place are too dangerous for .NET to watch over without interfering, you may also notice that all the return types aren't actually returns you put in Vars as "out" types so the code can modify them in memory and then that information can be read back into your managed .NET code. As far as a way to get similar effects in Windows XP, the only way I can think of is using Windows Blinds and then making a translucent WPF form with a gradient background (with a glass like effect) it would be quite easy to do, but the window will look out of place in Vista and XP and I don't think that it is such a good idea.
Hope this helps :P
Simon