111,119
社区成员
发帖
与我相关
我的任务
分享
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
namespace Areo测试
{
public partial class window : Form
{
public window()
{
InitializeComponent();
}
[DllImport("kernel32")]
static extern int GetVersionExA(ref OSVERSIONINFO 系统信息);
[DllImport("user32")]
static extern long GetWindowLongA(int hWnd, int nIndex);
[DllImport("user32")]
static extern int SetWindowLongA(int hWnd, int nIndex, long dwNewLong);
[DllImport("user32")]
static extern int SetLayeredWindowAttributes(int hWnd, int cr, int alp, int index);
[DllImport("dwmapi")]
static extern int DwmIsCompositionEnabled(ref int pfEnabled);
[DllImport("dwmapi")]
static extern int DwmEnableComposition(int uCompositionAction);
[DllImport("dwmapi")]
static extern int DwmExtendFrameIntoClientArea(int hWnd, ref _MARGINS pMarInset);
[DllImport("dwmapi")]
static extern int DwmEnableBlurBehindWindow(int hWnd, ref _DWM_BLURBEHIND pBlurBehind);
int hWnd = new int();//定义程序集变量
public struct OSVERSIONINFO
{
public int dwOSVersionInfoSize;
public int dwMajorVersion;
public int dwMinorVersion;
public int dwBuildNumber;
public int dwPlatformId;
}
public struct _MARGINS
{
public int cxLeftWidth;
public int cxRightWidth;
public int cyTopHeight;
public int cyBottomHeight;
}
public struct _DWM_BLURBEHIND
{
public int dwFlags;
public int fEnable;
public int hRgnBlur;
public int fTransitionOnMaximized;
}
private void Form1_Load(object sender, EventArgs e)
{
hWnd = Handle.ToInt32();
//判断系统版本,6和6以上版本可以使用
OSVERSIONINFO 版本信息 = new OSVERSIONINFO();
版本信息.dwOSVersionInfoSize = 148;
GetVersionExA(ref 版本信息);
if (版本信息.dwMajorVersion < 6)
{
MessageBox.Show("当前系统版本无法使用Areo!");
DestroyHandle();
}
long nIndex = GetWindowLongA(hWnd, -20);
nIndex = nIndex | 524288;
SetWindowLongA(hWnd, -20, nIndex);
SetLayeredWindowAttributes(hWnd, 16711680, 255, 1);
}
private void button1_Click(object sender, EventArgs e)
{
int pfEnabled = new int();
DwmIsCompositionEnabled(ref pfEnabled);
if (pfEnabled == 1)
{
MessageBox.Show("该系统开启了Areo效果");
}
else
{
MessageBox.Show("该系统没有开启Areo效果");
}
}
private void button2_Click(object sender, EventArgs e)
{
DwmEnableComposition(0);
MessageBox.Show("已经在当前进程关闭Aero 退出进程后界面会自动恢复");
}
private void button3_Click(object sender, EventArgs e)
{
DwmEnableComposition(1);
MessageBox.Show("已经在当前进程开启Aero 退出进程后界面会自动恢复");
}
private void button4_Click(object sender, EventArgs e)
{
this.BackColor = ColorTranslator.FromWin32(16711680);
checkedListBox1.BackColor = ColorTranslator.FromWin32(16711680);
progressBar1.BackColor = ColorTranslator.FromWin32(16711680);
textBox1.BackColor = ColorTranslator.FromWin32(16711680);
tabPage1.BackColor = ColorTranslator.FromWin32(16711680);
tabPage2.BackColor = ColorTranslator.FromWin32(16711680);
tabPage1.ForeColor = ColorTranslator.FromWin32(16711680);
tabPage2.ForeColor = ColorTranslator.FromWin32(16711680);
_MARGINS sRT = new _MARGINS();
sRT.cxLeftWidth = -1;
DwmExtendFrameIntoClientArea(hWnd, ref sRT);
}
}
}
string str="good";