Glass Effect using dwmapi.dll in windows xp on C#
-
Hii i am writing a code to make the glass effect on windows form. Well the code works fine on vista but my target is on windows xp. I have copyed all the dll's that are reqired and when i debug i am getting an error "DLL NOT FOUND EXCEPTION UNHANDILED". Here is the code that i am using:- ----------------------------------------------------------------------------------------------------------------------------- This is the class where i import dwmapi dll. using System; using System.Collections.Generic; using System.Text; using System.Runtime.InteropServices; namespace welcome_page { class VistaGlassEffect { internal class VistaApi { [DllImport("dwmapi.dll")] internal static extern void DwmExtendFrameIntoClientArea(System.IntPtr hWnd, ref Margins pMargins); [DllImport("dwmapi.dll")] internal static extern void DwmIsCompositionEnabled(ref bool isEnabled); internal struct Margins { public int Left, Right, Top, Bottom; } // consts for wndproc internal const int WM_NCHITTEST = 0x84; internal const int HTCLIENT = 1; internal const int HTCAPTION = 2; } } } ----------------------------------------------------------------------------------------------------------------------------- This the form where i call this class "VistaGlassEffect" using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using Microsoft.DirectX.AudioVideoPlayback; using System.Diagnostics; using System.Drawing.Drawing2D; namespace welcome_page { public partial class Form2 : Form { public Form2() { InitializeComponent(); this.FitGlass(); } Video video; private welcome_page.VistaGlassEffect.VistaApi.Margins marg; private Rectangle topRect = Rectangle.Empty; private Rectangle botRect = Rectangle.Empty; private Rectangle lefRect = Rectangle.Empty; private Rectangle rigRect = Rectangle.Empty; private void FitGlass() { // If DWM is not enabled then get out if (!this.IsGlassEnabled()) { return; } // Set the Margins to their default values marg.Top = 600; // extend from the
-
Hii i am writing a code to make the glass effect on windows form. Well the code works fine on vista but my target is on windows xp. I have copyed all the dll's that are reqired and when i debug i am getting an error "DLL NOT FOUND EXCEPTION UNHANDILED". Here is the code that i am using:- ----------------------------------------------------------------------------------------------------------------------------- This is the class where i import dwmapi dll. using System; using System.Collections.Generic; using System.Text; using System.Runtime.InteropServices; namespace welcome_page { class VistaGlassEffect { internal class VistaApi { [DllImport("dwmapi.dll")] internal static extern void DwmExtendFrameIntoClientArea(System.IntPtr hWnd, ref Margins pMargins); [DllImport("dwmapi.dll")] internal static extern void DwmIsCompositionEnabled(ref bool isEnabled); internal struct Margins { public int Left, Right, Top, Bottom; } // consts for wndproc internal const int WM_NCHITTEST = 0x84; internal const int HTCLIENT = 1; internal const int HTCAPTION = 2; } } } ----------------------------------------------------------------------------------------------------------------------------- This the form where i call this class "VistaGlassEffect" using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using Microsoft.DirectX.AudioVideoPlayback; using System.Diagnostics; using System.Drawing.Drawing2D; namespace welcome_page { public partial class Form2 : Form { public Form2() { InitializeComponent(); this.FitGlass(); } Video video; private welcome_page.VistaGlassEffect.VistaApi.Margins marg; private Rectangle topRect = Rectangle.Empty; private Rectangle botRect = Rectangle.Empty; private Rectangle lefRect = Rectangle.Empty; private Rectangle rigRect = Rectangle.Empty; private void FitGlass() { // If DWM is not enabled then get out if (!this.IsGlassEnabled()) { return; } // Set the Margins to their default values marg.Top = 600; // extend from the
-
Hii i am writing a code to make the glass effect on windows form. Well the code works fine on vista but my target is on windows xp. I have copyed all the dll's that are reqired and when i debug i am getting an error "DLL NOT FOUND EXCEPTION UNHANDILED". Here is the code that i am using:- ----------------------------------------------------------------------------------------------------------------------------- This is the class where i import dwmapi dll. using System; using System.Collections.Generic; using System.Text; using System.Runtime.InteropServices; namespace welcome_page { class VistaGlassEffect { internal class VistaApi { [DllImport("dwmapi.dll")] internal static extern void DwmExtendFrameIntoClientArea(System.IntPtr hWnd, ref Margins pMargins); [DllImport("dwmapi.dll")] internal static extern void DwmIsCompositionEnabled(ref bool isEnabled); internal struct Margins { public int Left, Right, Top, Bottom; } // consts for wndproc internal const int WM_NCHITTEST = 0x84; internal const int HTCLIENT = 1; internal const int HTCAPTION = 2; } } } ----------------------------------------------------------------------------------------------------------------------------- This the form where i call this class "VistaGlassEffect" using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using Microsoft.DirectX.AudioVideoPlayback; using System.Diagnostics; using System.Drawing.Drawing2D; namespace welcome_page { public partial class Form2 : Form { public Form2() { InitializeComponent(); this.FitGlass(); } Video video; private welcome_page.VistaGlassEffect.VistaApi.Margins marg; private Rectangle topRect = Rectangle.Empty; private Rectangle botRect = Rectangle.Empty; private Rectangle lefRect = Rectangle.Empty; private Rectangle rigRect = Rectangle.Empty; private void FitGlass() { // If DWM is not enabled then get out if (!this.IsGlassEnabled()) { return; } // Set the Margins to their default values marg.Top = 600; // extend from the
You asked this question here[^] and were told you couldn't do this using dwmapi.dll. This is a Vista+ only DLL, and copying it onto XP doesn't mean it'll work on XP. If your logic held true, then I'd only need to get a Ferrari keyring to convert my car into one. Bottom line - you can't do this with dwmapi, find another way and stop bumping posts.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith
As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
-
Hii i am writing a code to make the glass effect on windows form. Well the code works fine on vista but my target is on windows xp. I have copyed all the dll's that are reqired and when i debug i am getting an error "DLL NOT FOUND EXCEPTION UNHANDILED". Here is the code that i am using:- ----------------------------------------------------------------------------------------------------------------------------- This is the class where i import dwmapi dll. using System; using System.Collections.Generic; using System.Text; using System.Runtime.InteropServices; namespace welcome_page { class VistaGlassEffect { internal class VistaApi { [DllImport("dwmapi.dll")] internal static extern void DwmExtendFrameIntoClientArea(System.IntPtr hWnd, ref Margins pMargins); [DllImport("dwmapi.dll")] internal static extern void DwmIsCompositionEnabled(ref bool isEnabled); internal struct Margins { public int Left, Right, Top, Bottom; } // consts for wndproc internal const int WM_NCHITTEST = 0x84; internal const int HTCLIENT = 1; internal const int HTCAPTION = 2; } } } ----------------------------------------------------------------------------------------------------------------------------- This the form where i call this class "VistaGlassEffect" using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using Microsoft.DirectX.AudioVideoPlayback; using System.Diagnostics; using System.Drawing.Drawing2D; namespace welcome_page { public partial class Form2 : Form { public Form2() { InitializeComponent(); this.FitGlass(); } Video video; private welcome_page.VistaGlassEffect.VistaApi.Margins marg; private Rectangle topRect = Rectangle.Empty; private Rectangle botRect = Rectangle.Empty; private Rectangle lefRect = Rectangle.Empty; private Rectangle rigRect = Rectangle.Empty; private void FitGlass() { // If DWM is not enabled then get out if (!this.IsGlassEnabled()) { return; } // Set the Margins to their default values marg.Top = 600; // extend from the
Viswa Teja wrote:
works fine on vista but my target is on windows xp. I have copyed all the dll's that are reqired
This will not work. You cannot copy those .DLL's from a Vista system and expect them to work on XP. The rendering system work quite a bit differently. As for the error that you're getting, what you didn't take into account is that the .DLL's you copied are depending on other .DLL's themselves which you haven't copied and that cannot be loaded because of other problems, not the least of which is you're trying to run Vista .DLL's on an XP system.
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007, 2008
But no longer in 2009...