AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Sprachen und Entwicklungsumgebungen Object-Pascal / Delphi-Language Delphi Set & Windows Konstanten - abfragen & setzen
Thema durchsuchen
Ansicht
Themen-Optionen

Set & Windows Konstanten - abfragen & setzen

Ein Thema von Andreas L. · begonnen am 5. Jul 2019 · letzter Beitrag vom 5. Jul 2019
Antwort Antwort
Seite 1 von 2  1 2      
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
Benutzerbild von Luckie
Luckie

Registriert seit: 29. Mai 2002
37.621 Beiträge
 
Delphi 2006 Professional
 
#2

AW: Set & Windows Konstanten - abfragen & setzen

  Alt 5. Jul 2019, 10:23
Setzen bzw. hinzufügen mit or, nicht mit +! Abfragen mit and.
http://michael-puff.de/Programmierun...itMasken.shtml
Michael
Ein Teil meines Codes würde euch verunsichern.
  Mit Zitat antworten Zitat
Andreas L.

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

AW: Set & Windows Konstanten - abfragen & setzen

  Alt 5. Jul 2019, 10:31
Setzen bzw. hinzufügen mit or, nicht mit +! Abfragen mit and.
http://michael-puff.de/Programmierun...itMasken.shtml
Bei folgende Code erhalte ich die Meldung "Ausdruckstyp muss BOOLEAN sein" vom Compiler. Wie muss ich die Abfrage formulieren?

Delphi-Quellcode:
  if AWindowAnimations and AW_ACTIVATE then
    Result := Result + [lwaoActivate];
EDIT: Hab deinen Link eben erst gesehen. So müsste es stimmen, oder?

Delphi-Quellcode:
  if AWindowAnimations and AW_ACTIVATE = AW_ACTIVATE then
    Result := Result + [lwaoActivate];
Andreas Lauß
Blog
  Mit Zitat antworten Zitat
Benutzerbild von Neutral General
Neutral General

Registriert seit: 16. Jan 2004
Ort: Bendorf
5.219 Beiträge
 
Delphi 10.2 Tokyo Professional
 
#4

AW: Set & Windows Konstanten - abfragen & setzen

  Alt 5. Jul 2019, 10:32
if (AWindowAnimations and AW_ACTIVATE) <> 0 then
Michael
"Programmers talk about software development on weekends, vacations, and over meals not because they lack imagination,
but because their imagination reveals worlds that others cannot see."
  Mit Zitat antworten Zitat
EWeiss
(Gast)

n/a Beiträge
 
#5

AW: Set & Windows Konstanten - abfragen & setzen

  Alt 5. Jul 2019, 10:36
Setzen bzw. hinzufügen mit or, nicht mit +! Abfragen mit and.
http://michael-puff.de/Programmierun...itMasken.shtml
Bei folgende Code erhalte ich die Meldung "Ausdruckstyp muss BOOLEAN sein" vom Compiler. Wie muss ich die Abfrage formulieren?

Delphi-Quellcode:
  if AWindowAnimations and AW_ACTIVATE then
    Result := Result + [lwaoActivate];
EDIT: Hab deinen Link eben erst gesehen. So müsste es stimmen, oder?

Delphi-Quellcode:
  if AWindowAnimations and AW_ACTIVATE = AW_ACTIVATE then
    Result := Result + [lwaoActivate];
Ja wenn du auf Gleichheit prüfen willst ansonsten gilt das von @Neutral General <> also ungleich.

gruss
  Mit Zitat antworten Zitat
Benutzerbild von Luckie
Luckie

Registriert seit: 29. Mai 2002
37.621 Beiträge
 
Delphi 2006 Professional
 
#6

AW: Set & Windows Konstanten - abfragen & setzen

  Alt 5. Jul 2019, 10:37
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.
Michael
Ein Teil meines Codes würde euch verunsichern.
  Mit Zitat antworten Zitat
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
Andreas L.

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

AW: Set & Windows Konstanten - abfragen & setzen

  Alt 5. Jul 2019, 10:40
if (AWindowAnimations and AW_ACTIVATE) <> 0 then
Also muss es so lauten:

Delphi-Quellcode:
  if AWindowAnimations and AW_ACTIVATE <> 0 then
    Result := Result + [lwaoActivate];
Der Compiler akzeptiert es jedenfalls...

Danke für euer Hilfe
Andreas Lauß
Blog
  Mit Zitat antworten Zitat
EWeiss
(Gast)

n/a Beiträge
 
#9

AW: Set & Windows Konstanten - abfragen & setzen

  Alt 5. Jul 2019, 10:41
if (AWindowAnimations and AW_ACTIVATE) <> 0 then
Also muss es so lauten:

Delphi-Quellcode:
  if AWindowAnimations and AW_ACTIVATE <> 0 then
    Result := Result + [lwaoActivate];
Der Compiler akzeptiert es jedenfalls...

Danke für euer Hilfe
Das ist die frage wir wissen ja nicht was du willst.
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

Geändert von EWeiss ( 5. Jul 2019 um 10:44 Uhr)
  Mit Zitat antworten Zitat
Andreas L.

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

AW: Set & Windows Konstanten - abfragen & setzen

  Alt 5. Jul 2019, 10:44
Ein record helper kann mit einem Enumerator bzw. Set verwendet werden? Wow... Gibt es den record helper schon in Delphi 2009 Pro?
Andreas Lauß
Blog
  Mit Zitat antworten Zitat
Antwort Antwort
Seite 1 von 2  1 2      


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 09:09 Uhr.
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz