![]() |
Delphi-Version: 2009
Set & Windows Konstanten - abfragen & setzen
Hallo,
ich habe folgenden Enumerator & ein Set:
Delphi-Quellcode:
Wie kann ich alle in einer DWORD-Variable gesetzten Werte ermitteln um das Set (TlcfWindowAnimationOptions) zu füllen?
// https://docs.microsoft.com/de-de/windows/win32/api/winuser/nf-winuser-animatewindow
TlcfWindowAnimationOption = ( lwaoActivate, // AW_ACTIVATE = 0x00020000 - Nicht mit Hide verwenden! lwaoBlend, // AW_BLEND = 0x00080000 lwaoCenter, // AW_CENTER = 0x00000010 - lwaoHide, // AW_HIDE = 0x00010000 - lwaoHorizontalPositive, // AW_HOR_POSITIVE = 0x00000001 - Wird ignoriert bei AW_CENTER oder AW_BLEND lwaoHorizontalNegative, // AW_HOR_NEGATIVE = 0x00000002 - Wird ignoriert bei AW_CENTER oder AW_BLEND lwaoSlide, // AW_SLIDE = 0x00040000 - Wird ignoriert bei AW_CENTER lwaoVerticalPositive, // AW_VER_POSITIVE = 0x00000004 - Wird ignoriert bei AW_CENTER oder AW_BLEND lwaoVerticalNegative // AW_VER_NEGATIVE = 0x00000008 - Wird ignoriert bei AW_CENTER oder AW_BLEND ); TlcfWindowAnimationOptions = set of TlcfWindowAnimationOption; Ich habe folgendes versucht:
Delphi-Quellcode:
Ist das so richtig?
class function TlcfWindowHelper.GetWindowAnimations(
AWindowAnimation: DWORD): TlcfWindowAnimationOptions; begin Result := []; if AW_ACTIVATE in AWindowAnimation then Result := Result + [lwaoActivate]; //... end; Wenn ich außerdem das selbe nur andersrum machen will, muss ich die Werte mit "and" oder "or" verknüpfen?
Delphi-Quellcode:
Ist es außerdem richtig das Result mit 0 zu initialisieren?
class function TlcfWindowHelper.GetWindowAnimations(
AWindowAnimation: TlcfWindowAnimationOptions): DWORD; begin Result := 0; if lwaoActivate in AWindowAnimation then Result := Result or AW_ACTIVATE; // oder mit and??? end; Schöne Grüße, Andreas Lauß |
AW: Set & Windows Konstanten - abfragen & setzen
Setzen bzw. hinzufügen mit or, nicht mit +! Abfragen mit and.
![]() |
AW: Set & Windows Konstanten - abfragen & setzen
Zitat:
Delphi-Quellcode:
EDIT: Hab deinen Link eben erst gesehen. So müsste es stimmen, oder?
if AWindowAnimations and AW_ACTIVATE then
Result := Result + [lwaoActivate];
Delphi-Quellcode:
if AWindowAnimations and AW_ACTIVATE = AW_ACTIVATE then
Result := Result + [lwaoActivate]; |
AW: Set & Windows Konstanten - abfragen & setzen
Delphi-Quellcode:
if (AWindowAnimations and AW_ACTIVATE) <> 0 then
|
AW: Set & Windows Konstanten - abfragen & setzen
Zitat:
gruss |
AW: Set & Windows Konstanten - abfragen & setzen
Der Code ist noch vom vorm Kriech. Eventuell sogar mit Delphi 7 erstellt. Eventuell hat sich da was geändert in den neueren Delphis. Das kann ich jetzt aber nicht überprüfen. Jedenfalls hat der Code compiliert, sonst hätte ich ihn so nicht veröffentlicht.
|
AW: Set & Windows Konstanten - abfragen & setzen
Du könntest das als Vorlage verwenden
Delphi-Quellcode:
uses
Winapi.Windows; type // https://docs.microsoft.com/de-de/windows/win32/api/winuser/nf-winuser-animatewindow TlcfWindowAnimationOption = ( // lwaoActivate, // AW_ACTIVATE = 0x00020000 - Nicht mit Hide verwenden! lwaoBlend, // AW_BLEND = 0x00080000 lwaoCenter, // AW_CENTER = 0x00000010 - lwaoHide, // AW_HIDE = 0x00010000 - lwaoHorizontalPositive, // AW_HOR_POSITIVE = 0x00000001 - Wird ignoriert bei AW_CENTER oder AW_BLEND lwaoHorizontalNegative, // AW_HOR_NEGATIVE = 0x00000002 - Wird ignoriert bei AW_CENTER oder AW_BLEND lwaoSlide, // AW_SLIDE = 0x00040000 - Wird ignoriert bei AW_CENTER lwaoVerticalPositive, // AW_VER_POSITIVE = 0x00000004 - Wird ignoriert bei AW_CENTER oder AW_BLEND lwaoVerticalNegative // AW_VER_NEGATIVE = 0x00000008 - Wird ignoriert bei AW_CENTER oder AW_BLEND ); TlcfWindowAnimationOptions = set of TlcfWindowAnimationOption; THelperForTlcfWindowAnimationOptions = record helper for TlcfWindowAnimationOptions private const Values: array [TlcfWindowAnimationOption] of DWORD = (AW_ACTIVATE, AW_BLEND, AW_CENTER, AW_HIDE, AW_HOR_POSITIVE, AW_HOR_NEGATIVE, AW_SLIDE, AW_VER_POSITIVE, AW_VER_NEGATIVE); public function ToDword(): DWORD; class function FromDword(Value: DWORD): TlcfWindowAnimationOptions; static; end; implementation { THelperForTlcfWindowAnimationOptions } class function THelperForTlcfWindowAnimationOptions.FromDword(Value: DWORD): TlcfWindowAnimationOptions; var enum: TlcfWindowAnimationOption; begin Result := []; for enum := Low(TlcfWindowAnimationOption) to High(TlcfWindowAnimationOption) do begin if Values[enum] and Value = Values[enum] then Result := Result + [enum]; end; end; function THelperForTlcfWindowAnimationOptions.ToDword: DWORD; var enum: TlcfWindowAnimationOption; begin Result := 0; for enum := Low(TlcfWindowAnimationOption) to High(TlcfWindowAnimationOption) do if enum in Self then Result := Result or Values[enum]; end; |
AW: Set & Windows Konstanten - abfragen & setzen
Zitat:
Delphi-Quellcode:
Der Compiler akzeptiert es jedenfalls...
if AWindowAnimations and AW_ACTIVATE <> 0 then
Result := Result + [lwaoActivate]; Danke für euer Hilfe :) |
AW: Set & Windows Konstanten - abfragen & setzen
Zitat:
Auf Gleichheit abfragen oder ungleich.. PS: Ja ich weis was er abfragen und welches Ergebnis er erwartet aber hat er verstanden um was es geht? gruss |
AW: Set & Windows Konstanten - abfragen & setzen
Ein record helper kann mit einem Enumerator bzw. Set verwendet werden? Wow... Gibt es den record helper schon in Delphi 2009 Pro?
|
AW: Set & Windows Konstanten - abfragen & setzen
Zitat:
|
Alle Zeitangaben in WEZ +1. Es ist jetzt 11:08 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz