Sign in Join
Wiki copytemporary

Aero Glass/de: what changed

Revision 1 to 2. Removed lines have a minus sign; added lines have a plus sign.

OldNewLine
11## Der Aero-Glass-Effekt in einem Lazarus-Formular
22
3-<figure>
4-<img src="aero_glass_lazarus.png" title="aero_glass_lazarus.png" />
5-<figcaption>aero_glass_lazarus.png</figcaption>
6-</figure>
3+![](/wiki-images/5/5b/Aero_glass_lazarus.png)
74
85**Hinweis:** Funktioniert nur mit Windows !
96
107Speichern Sie zuerst den nachfolgenden Code in einer Textdatei namens "glass.pas":
118
129``` pascal
1310// Aero Glass Effekt für Delphi-Forms
1411//
1512// Mit der Methode GlassForm kann für eine Form der
1613// Aero Glass Effekt unter Vista aktiviert werden.
1714// Der erste Parameter ist die Form-Klasse, der zweite
1815// optionale Parameter ist der BlurColorKey. Mit dem
1916// BlurColorKey wird eine Farbe festgelegt, auf dem
2017// der Effekt wirken soll, d.h. benutzt eine Komponente,
2118// auf der Form, für visuelle Darstellungen (Linien, Punkte,
2219// Bilder, ...), diese Farbe, so wird an dieser Stelle der
2320// Effekt wirksam. Der Standardwert für BlurColorKey ist
2421// clFuchsia.
2522//
2623// Hinweis: Für die Aktivierung wird zusätzlich TXPManifest
2724// bzw. eine RES-Datei die die Manifest-Daten
2825// enthält benötigt.
2926//
3027//
3128// Delphi-Unit von Daniel Mitte (2006)
3229//
3330//
3431// Beispiel:
3532//
3633// uses glass;
3734//
3835// [...]
3936//
4037// procedure TForm1.FormActivate(Sender: TObject);
4138// begin
4239// GlassForm(Form1);
4340// // oder mit anderem BlurColorKey
4441// // GlassForm(Form1, clBlue)
4542// end;
4643
4744unit glass;
4845
4946interface
5047
5148{$mode delphi}
5249
5350uses
5451 Windows,
5552 Forms,
5653 Graphics;
5754
5855procedure GlassForm(frm: TForm; cBlurColorKey: TColor = clFuchsia);
5956
6057implementation
6158
6259procedure GlassForm(frm: TForm; cBlurColorKey: TColor = clFuchsia);
6360const
6461 WS_EX_LAYERED = $80000;
6562 LWA_COLORKEY = 1;
6663
6764type
6865 _MARGINS = packed record
6966 cxLeftWidth: Integer;
7067 cxRightWidth: Integer;
7168 cyTopHeight: Integer;
7269 cyBottomHeight: Integer;
7370 end;
7471 PMargins = ^_MARGINS;
7572 TMargins = _MARGINS;
7673
7774 DwmIsCompositionEnabledFunc = function(pfEnabled: PBoolean): HRESULT; stdcall;
7875 DwmExtendFrameIntoClientAreaFunc = function(destWnd: HWND; const pMarInset: PMargins): HRESULT; stdcall;
7976 SetLayeredWindowAttributesFunc = function(destWnd: HWND; cKey: TColor; bAlpha: Byte; dwFlags: DWord): BOOL; stdcall;
8077
8178var
8279 hDWMDLL: Cardinal;
8380 osVinfo: TOSVERSIONINFO;
8481 fDwmIsCompositionEnabled: DwmIsCompositionEnabledFunc;
8582 fDwmExtendFrameIntoClientArea: DwmExtendFrameIntoClientAreaFunc;
8683 fSetLayeredWindowAttributesFunc: SetLayeredWindowAttributesFunc;
8784 bCmpEnable: Boolean;
8885 mgn: TMargins;
8986
9087begin
9188 ZeroMemory(@osVinfo, SizeOf(osVinfo));
9289 OsVinfo.dwOSVersionInfoSize := SizeOf(TOSVERSIONINFO);
9390
9491 if ((GetVersionEx(osVInfo) = True) and (osVinfo.dwPlatformId = VER_PLATFORM_WIN32_NT) and (osVinfo.dwMajorVersion >= 6)) then
9592 begin
9693 hDWMDLL := LoadLibrary('dwmapi.dll');
9794
9895 if hDWMDLL <> 0 then
9996 begin
10097 @fDwmIsCompositionEnabled := GetProcAddress(hDWMDLL, 'DwmIsCompositionEnabled');
10198 @fDwmExtendFrameIntoClientArea := GetProcAddress(hDWMDLL, 'DwmExtendFrameIntoClientArea');
10299 @fSetLayeredWindowAttributesFunc := GetProcAddress(GetModulehandle(user32), 'SetLayeredWindowAttributes');
103100
104101 if ((@fDwmIsCompositionEnabled <> nil) and (@fDwmExtendFrameIntoClientArea <> nil) and (@fSetLayeredWindowAttributesFunc <> nil)) then
105102 begin
106103 fDwmIsCompositionEnabled(@bCmpEnable);
107104
108105 if bCmpEnable = True then
109106 begin
110107 frm.Color := cBlurColorKey;
111108
112109 SetWindowLong(frm.Handle, GWL_EXSTYLE, GetWindowLong(frm.Handle, GWL_EXSTYLE) or WS_EX_LAYERED);
113110 fSetLayeredWindowAttributesFunc(frm.Handle, cBlurColorKey, 0, LWA_COLORKEY);
114111
115112 ZeroMemory(@mgn, SizeOf(mgn));
116113 mgn.cxLeftWidth := -1;
117114 mgn.cxRightWidth := -1;
118115 mgn.cyTopHeight := -1;
119116 mgn.cyBottomHeight := -1;
120117
121118 fDwmExtendFrameIntoClientArea(frm.Handle, @mgn);
122119 end;
123120 end;
124121
125122 FreeLibrary(hDWMDLL);
126123 end;
127124 end;
128125end;
129126
130127end.
131128```
132129
133130Kopieren Sie die Datei "glass.pas" in den Hauptordner Ihres Projektes:
134131
135132` MeinProjekt\glass.pas`\
136133` `
137134
138135Fügen Sie im Abschnitt "uses" Ihres Projektes das Wort "glass" hinzu:
139136
140137``` pascal
141138unit form1;
142139
143140{$mode objfpc}{$H+}
144141
145142interface
146143
147144uses
148145 Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs
149146 glass; // Dadurch wird die Prozedur 'GlassForm' verfügbar gemacht
150147```
151148
152149Rufen Sie diese Prozedur im 'OnActivate'-Ereignis eines jeden Formulars auf:
153150
154151``` pascal
155152procedure TForm1.FormActivate(Sender: TObject);
156153begin
157154 GlassForm(Form1,clBlue); // Dies wendet den Aero-Glass-Effekt auf Form1 an
158155end;
159156```
160157
161158Außerdem müssen Sie *Themen* aktivieren, um diese Prozedur einsetzen zu können. Gehen Sie dazu zu Projektinspektor \> Einstellungen \> Projekteinstellungen \> und wählen Sie "Themen mit Manifest-Datei einschalten (nur in Windows)".
162159
163160## Fehler
164161
165162Wie Sie sehen können, werden die Labels im ersten Bild nicht sehr schön dargestellt in Aero Glass. Es folgen einige Links zu Komponenten und Code die zeigen, wie man "Labels zum Leuchten bringt":
166163
167164- [GlowLabel for Delphi](http://development.mwcs.de/glowlabel.html)
168165- [Aero Glass - ein Text (Label) hintergrund "machen"](http://www.delphipraxis.net/953968-post4.html)
169166
170167## Über
171168
172169Diese Komponente wurde zu Lazarus konvertiert mit "{\$mode delphi}". Sie stammt her von "Aero Glass Effekt für Delphi-Forms, Delphi-Unit von Daniel Mitte (2006)":
173170
174171- [Aero Glass Effekt für Delphi-Forms](http://www.delphipraxis.net/74538-aero-glass-effekt-fuer-delphi-forms.html)
175172
176173Es gibt eine Delphi-Komponente (die nach Lazarus portiert werden könnte) hier:
177174
178175- [D. Mitte in Torry's Delphi Page](http://www.torry.net/authorsmore.php?id=6179)
179176
180177---
181178*From the Free Pascal wiki, page "Aero Glass/de", as it stood on 2020-02-04 after a change by GAN, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).*
182179Category: Tutorials/de

Back to history