| Autor |
Beitrag |
HelgeLange
      
Beiträge: 735
Erhaltene Danke: 6
Windows 7
Delphi7 - Delphi XE
|
Verfasst: Sa 07.04.07 00:59
Auch mal 'ne Frage seit langer Zeit wieder...
ich habe ein Set, welches wie folgt deklariert ist :
Delphi-Quelltext 1: 2:
| THookAccessOption = (haoAlwaysStandardEvent, haoAllowMultipleEvents, haoReplaceEvent); THookAccessOptions = Set Of THookAccessOption; |
nun schliessen sich haoAllowMultipleEvents und haoReplaceEvent gegenseitig aus (aus logischen Gründen), aber all meine Versuche, das in einer Set-Methode hinzubekommen, schlugen fehl...
Ich weiss, dass man mit
Delphi-Quelltext 1: 2:
| if haoReplaceEvent in FHookAccessOptions Then ... |
testen kann, ob eine Option im Set enthalten ist und mit
Delphi-Quelltext 1:
| FHookAccessOptions := FHookAccessOptions - [haoAllowMultipleEvents]; |
kann man eine andere dann rausnehmen.. eigentlich...
Ideen ?
_________________ "Ich bin bekannt für meine Ironie. Aber auf den Gedanken, im Hafen von New York eine Freiheitsstatue zu errichten, wäre selbst ich nicht gekommen." - George Bernhard Shaw
|
|
BenBE
      
Beiträge: 8721
Erhaltene Danke: 191
Win95, Win98SE, Win2K, WinXP
D1S, D3S, D4S, D5E, D6E, D7E, D9PE, D10E, D12P, DXEP, L0.9\FPC2.0
|
Verfasst: Sa 07.04.07 12:42
Es gibt auch die Methoden Include und Exclude für Sets. Probier es mal mit denen ...
Ansonsten stell deine Frage mal noch etwas genauer oder gib mal einen etwas größeren Source-Block.
_________________ Anyone who is capable of being elected president should on no account be allowed to do the job.
Ich code EdgeMonkey - In dubio pro Setting.
|
|
HelgeLange 
      
Beiträge: 735
Erhaltene Danke: 6
Windows 7
Delphi7 - Delphi XE
|
Verfasst: Sa 07.04.07 14:53
uhm.. hatte ich ja eigentlich schon alles dazu geschrieben...
aber bitte schön :
Delphi-Quelltext 1: 2: 3: 4: 5: 6: 7: 8:
| procedure TERPHookAccessContainer.__SetHookAccessOptions(const Value: THookAccessOptions); begin If haoReplaceEvent in Value then Exclude(FHookAccessOptions, haoAllowMultipleEvents); If haoAllowMultipleEvents in Value Then Exclude(FHookAccessOptions, haoReplaceEvent); FHookAccessOptions := Value; end; |
Das Problem scheint zu nicht das Setzen zu sein (ich kenne Include/Exclude auch), sondern rauszubekommen, ob im originalen Wert etwas schon enthalten, was mit dem neuen Wert zusammen nicht da sein darf.
_________________ "Ich bin bekannt für meine Ironie. Aber auf den Gedanken, im Hafen von New York eine Freiheitsstatue zu errichten, wäre selbst ich nicht gekommen." - George Bernhard Shaw
|
|
BenBE
      
Beiträge: 8721
Erhaltene Danke: 191
Win95, Win98SE, Win2K, WinXP
D1S, D3S, D4S, D5E, D6E, D7E, D9PE, D10E, D12P, DXEP, L0.9\FPC2.0
|
Verfasst: Sa 07.04.07 15:55
_________________ Anyone who is capable of being elected president should on no account be allowed to do the job.
Ich code EdgeMonkey - In dubio pro Setting.
|
|
HelgeLange 
      
Beiträge: 735
Erhaltene Danke: 6
Windows 7
Delphi7 - Delphi XE
|
Verfasst: Sa 07.04.07 16:23
man kann auf Value nichts zuweisen, da es ein konstanter Wert ist, Habe es in eine temp-variable geschoben und mit der gearbeitet, jetzt geht es, danke BenBE
hier noch der Source, welcher funktioniert:
Delphi-Quelltext 1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13:
| procedure TERPHookAccessContainer.__SetHookAccessOptions(const Value: THookAccessOptions); var tempValue: THookAccessOptions; begin tempValue := Value; If (haoReplaceEvent in Value) And (haoAllowMultipleEvents in Value) Then begin tempValue := tempValue - [haoAllowMultipleEvents, haoReplaceEvent]; If haoReplaceEvent in FHookAccessOptions then Include(tempValue, haoAllowMultipleEvents); If haoAllowMultipleEvents in FHookAccessOptions Then Include(tempValue, haoReplaceEvent); end; FHookAccessOptions := tempValue; end; |
_________________ "Ich bin bekannt für meine Ironie. Aber auf den Gedanken, im Hafen von New York eine Freiheitsstatue zu errichten, wäre selbst ich nicht gekommen." - George Bernhard Shaw
|
|
BenBE
      
Beiträge: 8721
Erhaltene Danke: 191
Win95, Win98SE, Win2K, WinXP
D1S, D3S, D4S, D5E, D6E, D7E, D9PE, D10E, D12P, DXEP, L0.9\FPC2.0
|
Verfasst: Sa 07.04.07 18:16
Const ist auch nur Ansichtssache  Hatt ich mit Narses schon stundenlange Diskussionen darüber, ob es Konstanten gibt, zumal Delphi Property-Setter IIRC auch annimmt, wenn man Const nicht für die Parameterliste spezifiziert.
_________________ Anyone who is capable of being elected president should on no account be allowed to do the job.
Ich code EdgeMonkey - In dubio pro Setting.
|
|
|