Qt-在WIN10上实现毛玻璃效果(Aero效果,是C++语法)

相关资料:

https://blog.csdn.net/WPwalter/article/details/103268596   函数说明

https://download.csdn.net/download/qq_40110291/11501767   C++版本代码包下载

https://download.csdn.net/download/zhujianqiangqq/13092641    QT版本代码包下载

.pro

 1 QT       += core gui
 2 
 3 greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
 4 
 5 CONFIG += c++11
 6 
 7 # The following define makes your compiler emit warnings if you use
 8 # any Qt feature that has been marked deprecated (the exact warnings
 9 # depend on your compiler). Please consult the documentation of the
10 # deprecated API in order to know how to port your code away from it.
11 DEFINES += QT_DEPRECATED_WARNINGS
12 
13 # You can also make your code fail to compile if it uses deprecated APIs.
14 # In order to do so, uncomment the following line.
15 # You can also select to disable deprecated APIs only up to a certain version of Qt.
16 #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0
17 
18 SOURCES += 
19     aero.cpp 
20     main.cpp 
21     mainframe.cpp
22 
23 HEADERS += 
24     WindowCompositionAttribute.h 
25     aero.h 
26     mainframe.h
27 
28 FORMS += 
29     aero.ui 
30     mainframe.ui 
31     mainwindow.ui
32 
33 # Default rules for deployment.
34 qnx: target.path = /tmp/$${TARGET}/bin
35 else: unix:!android: target.path = /opt/$${TARGET}/bin
36 !isEmpty(target.path): INSTALLS += target
37 
38 RESOURCES +=
View Code

main.cpp

 1 #include <QApplication>
 2 
 3 #include "aero.h"
 4 
 5 int main(int argc, char *argv[])
 6 {
 7     QApplication a(argc, argv);
 8     Aero aero;
 9     aero.show();
10     return a.exec();
11 }
View Code

aero.h

 1 #ifndef AERO_H
 2 #define AERO_H
 3 
 4 #include <QtWidgets/QDialog>
 5 #include "ui_aero.h"
 6 #include "mainframe.h"
 7 #include <QPushButton>
 8 
 9 class Aero : public QDialog
10 {
11     Q_OBJECT
12 
13 public:
14     Aero(QWidget *parent = 0);
15     ~Aero();
16 
17     void paintEvent(QPaintEvent *);
18     void mouseMoveEvent(QMouseEvent *event);
19     void mousePressEvent(QMouseEvent *event);
20     void mouseReleaseEvent(QMouseEvent *event);
21     public slots:
22     void showMin();
23     void showColorD();
24     void slotchBgColor(QColor);
25     void slotsetAlph(int);
26 private:
27     Ui::AeroClass ui;
28     bool bFlag;
29     QPoint m_startPos;
30     QColor bgColor;
31     mainframe *pmainframe;
32     int m_alph;
33 
34     QPushButton *m_pPushButton;
35 };
36 
37 #endif // AERO_H
View Code

aero.cpp

 1 #include "aero.h"
 2 #include <windows.h>
 3  #include <WinUser.h>
 4  #include "WindowCompositionAttribute.h"
 5 
 6 #include <QPainter>
 7 #include <QMouseEvent>
 8 #include <QBitmap>
 9 #include <QColorDialog>
10 
11 
12  #pragma comment (lib,"user32.lib")
13 Aero::Aero(QWidget *parent)
14     : QDialog(parent)
15 {
16     ui.setupUi(this);
17     bgColor = QColor(255, 180, 180, 50);
18     m_alph = 50;
19     pmainframe = new mainframe();
20     connect(pmainframe, SIGNAL(chBgColor(QColor)), this, SLOT(slotchBgColor(QColor)));
21     connect(pmainframe, SIGNAL(setAlph(int)), this, SLOT(slotsetAlph(int)));
22     //setStyleSheet("border-radius:10px;");
23     this->setAttribute(Qt::WA_TranslucentBackground);
24     this->setWindowFlags(/*Qt::Dialog|*/Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint);
25     HWND hWnd = HWND(winId());
26     HMODULE hUser = GetModuleHandle(L"user32.dll");
27     if (hUser)
28     {
29         pfnSetWindowCompositionAttribute setWindowCompositionAttribute = (pfnSetWindowCompositionAttribute)GetProcAddress(hUser, "SetWindowCompositionAttribute");
30         if (setWindowCompositionAttribute)
31         {
32             ACCENT_POLICY accent = { ACCENT_ENABLE_BLURBEHIND, 0, 0, 0 };
33             WINDOWCOMPOSITIONATTRIBDATA data;
34             data.Attrib = WCA_ACCENT_POLICY;
35             data.pvData = &accent;
36             data.cbData = sizeof(accent);
37             setWindowCompositionAttribute(hWnd, &data);
38         }
39     }
40     connect(ui.btnClose, SIGNAL(clicked(bool)), this, SLOT(close()));
41     connect(ui.btnClose_hide, SIGNAL(clicked(bool)), this, SLOT(showMin()));
42     connect(ui.pushButton, SIGNAL(clicked(bool)), this, SLOT(showColorD()));
43 
44     m_pPushButton = new QPushButton(this);
45     m_pPushButton->setText(QStringLiteral("测试"));
46     m_pPushButton->setGeometry(100, 100, 100, 30);
47 }
48 
49 Aero::~Aero()
50 {
51 
52 }
53 void Aero::paintEvent(QPaintEvent *event)
54 {
55     QPainter painter(this);
56     painter.setRenderHint(QPainter::Antialiasing);
57     painter.setPen(Qt::NoPen);
58     painter.setBrush(bgColor);
59     painter.drawRoundedRect(rect(), 20, 20);
60     //painter.fillRect(ui.frame->rect(), bgColor);
61 }
62 void Aero::mouseMoveEvent(QMouseEvent *event)
63 {
64     QPoint point = event->globalPos() - m_startPos;
65     move(point);
66 }
67 
68 void Aero::mousePressEvent(QMouseEvent *event)
69 {
70     m_startPos = event->pos();
71 }
72 
73 void Aero::mouseReleaseEvent(QMouseEvent *event)
74 {
75 }
76 
77 void Aero::showMin()
78 {
79     showMinimized();
80 
81 }
82 
83 void Aero::showColorD()
84 {
85     pmainframe->show();
86 }
87 
88 void Aero::slotchBgColor(QColor color)
89 {
90     bgColor = color;
91     update();
92 }
93 
94 void Aero::slotsetAlph(int alph)
95 {
96     m_alph = alph;
97     bgColor.setAlpha(m_alph);
98     update();
99 }
View Code

aero.ui

  1 <?xml version="1.0" encoding="UTF-8"?>
  2 <ui version="4.0">
  3  <class>AeroClass</class>
  4  <widget class="QDialog" name="AeroClass">
  5   <property name="geometry">
  6    <rect>
  7     <x>0</x>
  8     <y>0</y>
  9     <width>527</width>
 10     <height>324</height>
 11    </rect>
 12   </property>
 13   <property name="windowTitle">
 14    <string>Dialog</string>
 15   </property>
 16   <property name="styleSheet">
 17    <string notr="true"/>
 18   </property>
 19   <layout class="QVBoxLayout" name="verticalLayout">
 20    <item>
 21     <widget class="QWidget" name="widget" native="true">
 22      <property name="styleSheet">
 23       <string notr="true">
 24 border-radius:20px;</string>
 25      </property>
 26      <layout class="QHBoxLayout" name="horizontalLayout_3">
 27       <property name="spacing">
 28        <number>6</number>
 29       </property>
 30       <property name="leftMargin">
 31        <number>7</number>
 32       </property>
 33       <property name="topMargin">
 34        <number>0</number>
 35       </property>
 36       <property name="rightMargin">
 37        <number>0</number>
 38       </property>
 39       <property name="bottomMargin">
 40        <number>0</number>
 41       </property>
 42       <item>
 43        <widget class="QLabel" name="label_2">
 44         <property name="minimumSize">
 45          <size>
 46           <width>20</width>
 47           <height>20</height>
 48          </size>
 49         </property>
 50         <property name="maximumSize">
 51          <size>
 52           <width>20</width>
 53           <height>20</height>
 54          </size>
 55         </property>
 56         <property name="styleSheet">
 57          <string notr="true">border-image: url(:/gif/Resources/wicon.jpg);</string>
 58         </property>
 59         <property name="text">
 60          <string/>
 61         </property>
 62        </widget>
 63       </item>
 64       <item>
 65        <widget class="QLabel" name="label">
 66         <property name="minimumSize">
 67          <size>
 68           <width>300</width>
 69           <height>0</height>
 70          </size>
 71         </property>
 72         <property name="font">
 73          <font>
 74           <family>Arial</family>
 75           <pointsize>11</pointsize>
 76           <weight>75</weight>
 77           <bold>true</bold>
 78          </font>
 79         </property>
 80         <property name="styleSheet">
 81          <string notr="true">color: rgb(62, 255, 33);
 82 </string>
 83         </property>
 84         <property name="text">
 85          <string>Apple  </string>
 86         </property>
 87        </widget>
 88       </item>
 89       <item>
 90        <widget class="QPushButton" name="pushButton">
 91         <property name="font">
 92          <font>
 93           <family>Arial</family>
 94           <pointsize>11</pointsize>
 95           <weight>75</weight>
 96           <bold>true</bold>
 97          </font>
 98         </property>
 99         <property name="styleSheet">
100          <string notr="true">color: rgb(62, 255, 33);</string>
101         </property>
102         <property name="text">
103          <string>换肤</string>
104         </property>
105        </widget>
106       </item>
107       <item>
108        <spacer name="horizontalSpacer_2">
109         <property name="orientation">
110          <enum>Qt::Horizontal</enum>
111         </property>
112         <property name="sizeHint" stdset="0">
113          <size>
114           <width>177</width>
115           <height>20</height>
116          </size>
117         </property>
118        </spacer>
119       </item>
120       <item>
121        <widget class="QPushButton" name="btnClose_hide">
122         <property name="minimumSize">
123          <size>
124           <width>60</width>
125           <height>30</height>
126          </size>
127         </property>
128         <property name="font">
129          <font>
130           <family>Arial</family>
131           <pointsize>16</pointsize>
132           <italic>true</italic>
133          </font>
134         </property>
135         <property name="styleSheet">
136          <string notr="true">QPushButton{color:#ffffff;}
137     QPushButton#btnClose,QPushButton#btnClose_hide{border:none;border-radius:0px;}
138     QPushButton#btnClose:hover,QPushButton#btnClose_hide:hover{background-color:#ff0000;}
139 </string>
140         </property>
141         <property name="text">
142          <string>_</string>
143         </property>
144        </widget>
145       </item>
146       <item>
147        <widget class="QPushButton" name="btnClose">
148         <property name="minimumSize">
149          <size>
150           <width>60</width>
151           <height>30</height>
152          </size>
153         </property>
154         <property name="font">
155          <font>
156           <family>微软雅黑</family>
157           <pointsize>18</pointsize>
158          </font>
159         </property>
160         <property name="styleSheet">
161          <string notr="true">QPushButton{color:#ffffff;}
162     QPushButton#btnClose,QPushButton#btnClose_hide{border:none;border-radius:0px;}
163     QPushButton#btnClose:hover,QPushButton#btnClose_hide:hover{background-color:#ff0000;}
164     QPushButton#btnClose,QPushButton#btnClose_hide{border-top-right-radius:20px;}</string>
165         </property>
166         <property name="text">
167          <string>x</string>
168         </property>
169        </widget>
170       </item>
171      </layout>
172     </widget>
173    </item>
174    <item>
175     <spacer name="verticalSpacer">
176      <property name="orientation">
177       <enum>Qt::Vertical</enum>
178      </property>
179      <property name="sizeHint" stdset="0">
180       <size>
181        <width>20</width>
182        <height>266</height>
183       </size>
184      </property>
185     </spacer>
186    </item>
187   </layout>
188   <zorder>widget</zorder>
189   <zorder>verticalSpacer</zorder>
190  </widget>
191  <resources/>
192  <connections/>
193 </ui>
View Code

mainframe.h

 1 #ifndef MAINFRAME_H
 2 #define MAINFRAME_H
 3 
 4 #include <QDialog>
 5 #include "ui_mainframe.h"
 6 #include <QSlider>
 7 
 8 class mainframe : public QDialog
 9 {
10     Q_OBJECT
11 
12 public:
13     mainframe(QWidget *parent = 0);
14     ~mainframe();
15     void paintEvent(QPaintEvent *event);
16     void mouseMoveEvent(QMouseEvent *event);
17     void mouseReleaseEvent(QMouseEvent *event);
18     void mousePressEvent(QMouseEvent *event);
19 public slots:
20     void showW();
21     void slotvalueChanged(int);
22 signals:
23     void chBgColor(QColor);
24     void setAlph(int);
25 private:
26     Ui::mainframe ui;
27     QPoint m_startPos;
28     QColor bgColor;
29     QSlider *pslider;
30     QVector<QLabel*> m_Vlabel;
31     int m_alph;
32 };
33 
34 #endif // MAINFRAME_H
View Code

mainframe.cpp

 1 #include "mainframe.h"
 2 #include <windows.h>
 3 #include <WinUser.h>
 4 #include "WindowCompositionAttribute.h"
 5 #include <QMouseEvent>
 6 #include <QPainter>
 7 #include <QLayoutItem>
 8 mainframe::mainframe(QWidget *parent)
 9     : QDialog(parent)
10 {
11     ui.setupUi(this);
12     pslider = new QSlider(this);
13     ui.gridLayout->addWidget(pslider,1,5,4,1,Qt::AlignHCenter);
14     connect(pslider, SIGNAL(valueChanged(int)), this, SLOT(slotvalueChanged(int)));
15     this->setAttribute(Qt::WA_TranslucentBackground);
16     this->setWindowFlags(Qt::Dialog | Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint);
17     for (int  i = 0; i < ui.gridLayout->count(); i++)
18     {
19         QLabel *plabel = static_cast<QLabel *>(ui.gridLayout->itemAt(i)->widget());
20         m_Vlabel.append(plabel);
21     }
22     bgColor = QColor(255, 180, 180, 50);
23     m_alph = 50;
24     HWND hWnd = HWND(winId());
25     HMODULE hUser = GetModuleHandle(L"user32.dll");
26     if (hUser)
27     {
28         pfnSetWindowCompositionAttribute setWindowCompositionAttribute = (pfnSetWindowCompositionAttribute)GetProcAddress(hUser, "SetWindowCompositionAttribute");
29         if (setWindowCompositionAttribute)
30         {
31             ACCENT_POLICY accent = { ACCENT_ENABLE_BLURBEHIND, 0, 0, 0 };
32             WINDOWCOMPOSITIONATTRIBDATA data;
33             data.Attrib = WCA_ACCENT_POLICY;
34             data.pvData = &accent;
35             data.cbData = sizeof(accent);
36             setWindowCompositionAttribute(hWnd, &data);
37         }
38     }
39 }
40 
41 mainframe::~mainframe()
42 {
43 
44 }
45 void mainframe::paintEvent(QPaintEvent *event)
46 {
47     QPainter painter(this);
48     painter.setRenderHint(QPainter::Antialiasing);
49     painter.setPen(Qt::NoPen);
50     painter.setBrush(bgColor);
51     painter.drawRoundedRect(rect(), 20, 20);
52     //painter.fillRect(ui.frame->rect(), bgColor);
53 }
54 void mainframe::mousePressEvent(QMouseEvent *event)
55 {
56     m_startPos = event->pos();
57     QPoint point = event->pos();
58     for (int i=0;i<m_Vlabel.size();i++)
59     {
60         if (m_Vlabel.at(i)->geometry().contains(point))
61         {
62             QPalette pal = m_Vlabel.at(i)->palette();
63             QBrush brush = pal.background();
64             QColor col = brush.color();
65             col.setAlpha(m_alph);
66             emit chBgColor(col);
67             return;
68         }
69     }
70 
71 }
72 void mainframe::mouseMoveEvent(QMouseEvent *event)
73 {
74     QPoint point = event->globalPos() - m_startPos;
75     move(point);
76 }
77 
78 void mainframe::mouseReleaseEvent(QMouseEvent *event)
79 {
80 
81 }
82 
83 void mainframe::showW()
84 {
85 }
86 
87 void mainframe::slotvalueChanged(int alph)
88 {
89     m_alph = alph;
90     bgColor.setAlpha(m_alph);
91     emit setAlph(alph);
92     update();
93 }
View Code

mainframe.ui

  1 <?xml version="1.0" encoding="UTF-8"?>
  2 <ui version="4.0">
  3  <class>mainframe</class>
  4  <widget class="QDialog" name="mainframe">
  5   <property name="geometry">
  6    <rect>
  7     <x>0</x>
  8     <y>0</y>
  9     <width>403</width>
 10     <height>300</height>
 11    </rect>
 12   </property>
 13   <property name="windowTitle">
 14    <string>Dialog</string>
 15   </property>
 16   <layout class="QGridLayout" name="gridLayout">
 17    <item row="4" column="3">
 18     <widget class="QLabel" name="label_22">
 19      <property name="styleSheet">
 20       <string notr="true">background-color: rgb(85, 0, 0);</string>
 21      </property>
 22      <property name="text">
 23       <string/>
 24      </property>
 25     </widget>
 26    </item>
 27    <item row="4" column="4">
 28     <widget class="QLabel" name="label_24">
 29      <property name="styleSheet">
 30       <string notr="true">background-color: rgb(85, 0, 255);</string>
 31      </property>
 32      <property name="text">
 33       <string/>
 34      </property>
 35     </widget>
 36    </item>
 37    <item row="4" column="1">
 38     <widget class="QLabel" name="label_21">
 39      <property name="styleSheet">
 40       <string notr="true">background-color: rgb(170, 0, 255);</string>
 41      </property>
 42      <property name="text">
 43       <string/>
 44      </property>
 45     </widget>
 46    </item>
 47    <item row="3" column="4">
 48     <widget class="QLabel" name="label_19">
 49      <property name="styleSheet">
 50       <string notr="true">background-color: rgb(0, 85, 0);</string>
 51      </property>
 52      <property name="text">
 53       <string/>
 54      </property>
 55     </widget>
 56    </item>
 57    <item row="4" column="0">
 58     <widget class="QLabel" name="label_25">
 59      <property name="styleSheet">
 60       <string notr="true">background-color: rgb(255, 0, 0);</string>
 61      </property>
 62      <property name="text">
 63       <string/>
 64      </property>
 65     </widget>
 66    </item>
 67    <item row="4" column="2">
 68     <widget class="QLabel" name="label_23">
 69      <property name="styleSheet">
 70       <string notr="true">background-color: rgb(0, 0, 127);</string>
 71      </property>
 72      <property name="text">
 73       <string/>
 74      </property>
 75     </widget>
 76    </item>
 77    <item row="2" column="4">
 78     <widget class="QLabel" name="label_15">
 79      <property name="styleSheet">
 80       <string notr="true">background-color: rgb(170, 85, 127);</string>
 81      </property>
 82      <property name="text">
 83       <string/>
 84      </property>
 85     </widget>
 86    </item>
 87    <item row="3" column="1">
 88     <widget class="QLabel" name="label_17">
 89      <property name="styleSheet">
 90       <string notr="true">background-color: rgb(255, 85, 255);</string>
 91      </property>
 92      <property name="text">
 93       <string/>
 94      </property>
 95     </widget>
 96    </item>
 97    <item row="2" column="3">
 98     <widget class="QLabel" name="label_11">
 99      <property name="styleSheet">
100       <string notr="true">background-color: rgb(170, 85, 0);</string>
101      </property>
102      <property name="text">
103       <string/>
104      </property>
105     </widget>
106    </item>
107    <item row="2" column="2">
108     <widget class="QLabel" name="label_10">
109      <property name="styleSheet">
110       <string notr="true">background-color: rgb(170, 170, 0);</string>
111      </property>
112      <property name="text">
113       <string/>
114      </property>
115     </widget>
116    </item>
117    <item row="3" column="0">
118     <widget class="QLabel" name="label_16">
119      <property name="styleSheet">
120       <string notr="true">background-color: rgb(255, 85, 0);</string>
121      </property>
122      <property name="text">
123       <string/>
124      </property>
125     </widget>
126    </item>
127    <item row="1" column="4">
128     <widget class="QLabel" name="label_13">
129      <property name="styleSheet">
130       <string notr="true">background-color: rgb(255, 170, 0);</string>
131      </property>
132      <property name="text">
133       <string/>
134      </property>
135     </widget>
136    </item>
137    <item row="2" column="1">
138     <widget class="QLabel" name="label_6">
139      <property name="styleSheet">
140       <string notr="true">background-color: rgb(170, 170, 127);</string>
141      </property>
142      <property name="text">
143       <string/>
144      </property>
145     </widget>
146    </item>
147    <item row="2" column="0">
148     <widget class="QLabel" name="label_14">
149      <property name="styleSheet">
150       <string notr="true">background-color: rgb(170, 170, 255);</string>
151      </property>
152      <property name="text">
153       <string/>
154      </property>
155     </widget>
156    </item>
157    <item row="3" column="2">
158     <widget class="QLabel" name="label_20">
159      <property name="styleSheet">
160       <string notr="true">background-color: rgb(85, 85, 255);</string>
161      </property>
162      <property name="text">
163       <string/>
164      </property>
165     </widget>
166    </item>
167    <item row="3" column="3">
168     <widget class="QLabel" name="label_18">
169      <property name="styleSheet">
170       <string notr="true">background-color: rgb(85, 85, 0);</string>
171      </property>
172      <property name="text">
173       <string/>
174      </property>
175     </widget>
176    </item>
177    <item row="0" column="2">
178     <widget class="QLabel" name="label_5">
179      <property name="styleSheet">
180       <string notr="true">background-color: rgb(0, 255, 127);</string>
181      </property>
182      <property name="text">
183       <string/>
184      </property>
185     </widget>
186    </item>
187    <item row="0" column="0">
188     <widget class="QLabel" name="label">
189      <property name="styleSheet">
190       <string notr="true">background-color: rgb(0, 255, 0);</string>
191      </property>
192      <property name="text">
193       <string/>
194      </property>
195     </widget>
196    </item>
197    <item row="1" column="1">
198     <widget class="QLabel" name="label_7">
199      <property name="styleSheet">
200       <string notr="true">background-color: rgb(255, 170, 255);</string>
201      </property>
202      <property name="text">
203       <string/>
204      </property>
205     </widget>
206    </item>
207    <item row="0" column="3">
208     <widget class="QLabel" name="label_3">
209      <property name="styleSheet">
210       <string notr="true">background-color: rgb(0, 255, 255);</string>
211      </property>
212      <property name="text">
213       <string/>
214      </property>
215     </widget>
216    </item>
217    <item row="1" column="2">
218     <widget class="QLabel" name="label_9">
219      <property name="styleSheet">
220       <string notr="true">background-color: rgb(255, 255, 0);</string>
221      </property>
222      <property name="text">
223       <string/>
224      </property>
225     </widget>
226    </item>
227    <item row="0" column="4">
228     <widget class="QLabel" name="label_2">
229      <property name="styleSheet">
230       <string notr="true">background-color: rgb(85, 255, 0);</string>
231      </property>
232      <property name="text">
233       <string/>
234      </property>
235     </widget>
236    </item>
237    <item row="0" column="1">
238     <widget class="QLabel" name="label_4">
239      <property name="styleSheet">
240       <string notr="true">background-color: rgb(170, 255, 0);</string>
241      </property>
242      <property name="text">
243       <string/>
244      </property>
245     </widget>
246    </item>
247    <item row="1" column="0">
248     <widget class="QLabel" name="label_8">
249      <property name="styleSheet">
250       <string notr="true">background-color: rgb(85, 255, 127);</string>
251      </property>
252      <property name="text">
253       <string/>
254      </property>
255     </widget>
256    </item>
257    <item row="1" column="3">
258     <widget class="QLabel" name="label_12">
259      <property name="styleSheet">
260       <string notr="true">background-color: rgb(255, 170, 127);</string>
261      </property>
262      <property name="text">
263       <string/>
264      </property>
265     </widget>
266    </item>
267    <item row="0" column="5">
268     <widget class="QLabel" name="label_26">
269      <property name="font">
270       <font>
271        <family>微软雅黑</family>
272        <pointsize>11</pointsize>
273        <weight>50</weight>
274        <bold>false</bold>
275       </font>
276      </property>
277      <property name="styleSheet">
278       <string notr="true">color: rgb(255, 178, 115);</string>
279      </property>
280      <property name="text">
281       <string>透明度</string>
282      </property>
283     </widget>
284    </item>
285   </layout>
286  </widget>
287  <resources/>
288  <connections/>
289 </ui>
View Code

WindowCompositionAttribute.h

 1 #pragma once
 2 
 3 typedef enum _WINDOWCOMPOSITIONATTRIB
 4 {
 5     WCA_UNDEFINED = 0,
 6     WCA_NCRENDERING_ENABLED = 1,
 7     WCA_NCRENDERING_POLICY = 2,
 8     WCA_TRANSITIONS_FORCEDISABLED = 3,
 9     WCA_ALLOW_NCPAINT = 4,
10     WCA_CAPTION_BUTTON_BOUNDS = 5,
11     WCA_NONCLIENT_RTL_LAYOUT = 6,
12     WCA_FORCE_ICONIC_REPRESENTATION = 7,
13     WCA_EXTENDED_FRAME_BOUNDS = 8,
14     WCA_HAS_ICONIC_BITMAP = 9,
15     WCA_THEME_ATTRIBUTES = 10,
16     WCA_NCRENDERING_EXILED = 11,
17     WCA_NCADORNMENTINFO = 12,
18     WCA_EXCLUDED_FROM_LIVEPREVIEW = 13,
19     WCA_VIDEO_OVERLAY_ACTIVE = 14,
20     WCA_FORCE_ACTIVEWINDOW_APPEARANCE = 15,
21     WCA_DISALLOW_PEEK = 16,
22     WCA_CLOAK = 17,
23     WCA_CLOAKED = 18,
24     WCA_ACCENT_POLICY = 19,
25     WCA_FREEZE_REPRESENTATION = 20,
26     WCA_EVER_UNCLOAKED = 21,
27     WCA_VISUAL_OWNER = 22,
28     WCA_LAST = 23
29 } WINDOWCOMPOSITIONATTRIB;
30 
31 typedef struct _WINDOWCOMPOSITIONATTRIBDATA
32 {
33     WINDOWCOMPOSITIONATTRIB Attrib;
34     PVOID pvData;
35     SIZE_T cbData;
36 } WINDOWCOMPOSITIONATTRIBDATA;
37 
38 typedef enum _ACCENT_STATE
39 {
40     ACCENT_DISABLED = 0,
41     ACCENT_ENABLE_GRADIENT = 1,
42     ACCENT_ENABLE_TRANSPARENTGRADIENT = 2,
43     ACCENT_ENABLE_BLURBEHIND = 3,
44     ACCENT_INVALID_STATE = 4
45 } ACCENT_STATE;
46 
47 typedef struct _ACCENT_POLICY
48 {
49     ACCENT_STATE AccentState;
50     DWORD AccentFlags;
51     DWORD GradientColor;
52     DWORD AnimationId;
53 } ACCENT_POLICY;
54 
55 WINUSERAPI
56 BOOL
57 WINAPI
58 GetWindowCompositionAttribute(
59     _In_ HWND hWnd,
60     _Inout_ WINDOWCOMPOSITIONATTRIBDATA* pAttrData);
61 
62 typedef BOOL(WINAPI*pfnGetWindowCompositionAttribute)(HWND, WINDOWCOMPOSITIONATTRIBDATA*);
63 
64 WINUSERAPI
65 BOOL
66 WINAPI
67 SetWindowCompositionAttribute(
68     _In_ HWND hWnd,
69     _Inout_ WINDOWCOMPOSITIONATTRIBDATA* pAttrData);
70 
71 typedef BOOL(WINAPI*pfnSetWindowCompositionAttribute)(HWND, WINDOWCOMPOSITIONATTRIBDATA*);
View Code
原文地址:https://www.cnblogs.com/FKdelphi/p/13938090.html