background preloader

Transparent DirectX windows

Facebook Twitter

Creating transparent windows. You may have seen some windows that have transparent portions, and wonder how you can do that in Delphi.

Creating transparent windows

It is quite easy, and there are several different ways to achieve the affect such as below: Layered windows and UpdateLayeredWind. Recently I was playing with transparent (layered) windows in Windows XP.

Layered windows and UpdateLayeredWind

The basic information about layered windows is available from MSDN, however the lack of information and examples for UpdateLayeredWindow() inspired me to write this article. To create a layered window flag WS_EX_LAYERED must be used. //here we create a layered window HWND hWnd = CreateWindowEx(WS_EX_TOPMOST | WS_EX_LAYERED, WNDCLASSNAME, \ WNDCAPTION, WS_POPUP , \ WINDOW_X, WINDOW_Y, \ WINDOW_WIDTH, WINDOW_HEIGHT, \ NULL, NULL, hInstance, NULL); "Windowless" DirectX? Transparent Window Sample. How do I draw transparent DirectX content in a transparent windo. Transparent and non-rectangular windows. I get a lot of questions about how to do transparent top-level windows in Avalon, or nonrectangular windows, or layered windows, or other variations on the same theme.

Transparent and non-rectangular windows

The short answer is you can do most of these things, but it’s really a Win32 feature rather than an Avalon feature, and you’ll do it using Win32 APIs. And some of this stuff works better on Longhorn, or at least will once we finish Longhorn. But the complete answer is quite a bit more involved… First thing to know is that the only thing the window manager understands is a good old-fashioned Win32 HWND. So every Avalon Window object is an hwnd. In Win32, you can get a non-rectangular window two different ways. Layered windows also allow you to make the entire window translucent (semi-transparent) by specifying an alpha value to apply to every pixel in the window. Layered windows, on the other hand, come with some limitations, because Avalon is unlike your typical hwnd and uses DirectX rather than GDI to render. Transparent Window without using Layers. Windows Layers Opacity and DirectX Problem. I am using C#, Managed DirectX, and .net 2.0.

Windows Layers Opacity and DirectX Problem

I have a form that has a panel that is rendered to by Managed DirectX. When I make the form's opacity anything except for 100% I get weird behavior. The window's title bar and border are semi-transparent like it's suposed to be but the panel that is being rendered to by Managed DirectX is solid opaque and flashes (it doesn't flash if the window is 100% opaque). However if I drag the window partialy outside the screen it works perfectly as it should. If I drag it back in it will work if I keep dragging it but than it appears that DirectX renders an opaque copy. A more full description of this problem and pictures can be found here: Transparent Windows in WPF. Introduction WPF can obviously render transparent elements within its own window, but it also supports rendering the entire window with per-pixel transparency.

Transparent Windows in WPF

This feature comes with a few issues, which I'll discuss in this post. Performance is poor in a WPF-based application in which you have. A computer has the Microsoft .NET Framework 3.0 installed.

Performance is poor in a WPF-based application in which you have

In an application that is based on the Windows Presentation Foundation (WPF), you enable layered windows by setting the value of the Windows.AllowsTransparency windows property to TRUE. In this configuration, the performance of the WPF-based application is poor. Additionally, you may notice the following problems: Jittery animationLower frame rate High CPU usage This problem occurs because layered windows enable the transparency effects of the top-level window.

WPF-based applications render graphics by using the DirectX pipeline. Note DirectX 9.0c is included with Microsoft Windows XP with Service Pack 2, with Microsoft Windows Server 2003 with Service Pack 1, and with Windows Server 2003 with Service Pack 2. Hotfix information. DirectX9.0 app + transparent window. Transparent Window Demo. Transparent WPF control over unmanaged window handle. [This blog was migrated.

Transparent WPF control over unmanaged window handle

You will not be able to comment here.The new URL of this post is All those, how even once tried to put opaque or transparent WPF control over Windows Forms control or, even unmanaged window found themselves within "Airspace problem". So, what to do? How can we use transparent WPF UI over our legacy windows? This how. See the image above. Protected override void OnSourceInitialized(EventArgs e) { HwndSource hwndSource = PresentationSource.FromVisual(this) as HwndSource; if (hwndSource ! So far, so good. [DllImport("user32.dll", SetLastError = true)] static extern IntPtr FindWindow(string lpClassName, string lpWindowName); Now let's enter endless loop for finding our handle IntPtr hWnd = FindWindow(null, (string)e.Argument); while (!

Once got it by name, we have to measure it and then resize our WPF window to fit the new size and position. [DllImport("user32.dll")] static extern bool GetWindowRect(IntPtr hWnd, out RECT lpRect); RECT r = new RECT(); while (! Layered Windows. Vadim Gorokhovsky and Lou Amadio Microsoft Corporation January 2000 Summary: Describes the new functionality included in Microsoft® Windows® 2000 that provides an efficient way to add transparency and translucency to top-level windows. (8 printed pages) Contents.

Layered Windows

UpdateLayeredWindow Function () Updates the position, size, shape, content, and translucency of a layered window.

UpdateLayeredWindow Function ()

Syntax. IDirect3DSurface9.