Einzelnen Beitrag anzeigen

Schokohase
(Gast)

n/a Beiträge
 
#7

AW: Set & Windows Konstanten - abfragen & setzen

  Alt 5. Jul 2019, 10:38
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;
  Mit Zitat antworten Zitat