Einzelnen Beitrag anzeigen

Andreas L.

Registriert seit: 23. Mai 2011
Ort: Furth im Wald
308 Beiträge
 
Delphi 11 Alexandria
 
#1

Set & Windows Konstanten - abfragen & setzen

  Alt 5. Jul 2019, 10:13
Delphi-Version: 2009
Hallo,

ich habe folgenden Enumerator & ein Set:

Delphi-Quellcode:
  // 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;
Wie kann ich alle in einer DWORD-Variable gesetzten Werte ermitteln um das Set (TlcfWindowAnimationOptions) zu füllen?

Ich habe folgendes versucht:

Delphi-Quellcode:
class function TlcfWindowHelper.GetWindowAnimations(
  AWindowAnimation: DWORD): TlcfWindowAnimationOptions;
begin
  Result := [];

  if AW_ACTIVATE in AWindowAnimation then
    Result := Result + [lwaoActivate];

  //...
end;
Ist das so richtig?

Wenn ich außerdem das selbe nur andersrum machen will, muss ich die Werte mit "and" oder "or" verknüpfen?

Delphi-Quellcode:
class function TlcfWindowHelper.GetWindowAnimations(
  AWindowAnimation: TlcfWindowAnimationOptions): DWORD;
begin
  Result := 0;

  if lwaoActivate in AWindowAnimation then
    Result := Result or AW_ACTIVATE; // oder mit and???
end;
Ist es außerdem richtig das Result mit 0 zu initialisieren?

Schöne Grüße,
Andreas Lauß
Andreas Lauß
Blog
  Mit Zitat antworten Zitat