![]() |
Übersetzung Class MagneticWindow
Wie in anderen Threads schon begonnen ..
Ich möchte meine Magnetic Class nach Delphi übersetzen um meinen MediPlayer stück für stück nach Delphi zu konvertieren. Die Classe emuliert die exakten Dockeigenschaften wie sie auch in Winamp zur verfügung stehen. Nach der Übersetzung werde ich sie hier zur verfügung stellen. Meine aktuelle frage.
Code:
Wie wird in Delphi Enum declariert ?
Vb:
Private Enum eMsgWhen [MSG_AFTER] = 1 [MSG_BEFORE] = 2 [MSG_BEFORE_AND_AFTER] = MSG_AFTER Or MSG_BEFORE End Enum gruß |
Re: Übersetzung Class MagneticWindow
Delphi-Quellcode:
Dabei wird aber die Wertbelegung anders gehandhabt. Das erste Element hat den Ordinalwert von 0, alle weiteren aufsteigend. Ich denke bei diesem Typ würde ein Set besser passen (vergleichbar mit einer Bitmaske):
Type
eMsgWhen = ( MSG_AFTER, MSG_BEFORE, MSG_BEFORE_AND_AFTER );
Delphi-Quellcode:
Dann hast du die Möglichkeit die Typen zu kombinieren:
Type
eMsgWhen = Set Of ( MSG_AFTER, MSG_BEFORE ); Beispiel:
Delphi-Quellcode:
Zu dem Hinzufügen und Entfernen kannst du auch die Funktionen Include() und Exclude() nutzen. Abfragen ob ein Element in der Menge ist geschieht mit IN:
Var
lVar: eMsgWhen; Begin lVar := []; // keins lVar := [MSG_AFTER, MSG_BEFORE]; // beide lVar := [MSG_AFTER]; // nur einer End;
Delphi-Quellcode:
If MSG_AFTER In lVar Then
ShowMessage('jo, after'); |
Re: Übersetzung Class MagneticWindow
Delphi-Quellcode:
wenn ich das richtig verstanden habe kann man den wert nicht direkt zuweisen.
Type
eMsgWhen = Set Of ( MSG_AFTER, MSG_BEFORE ); Würde bedeuten MSG_AFTER ist gleichzusetzen mit 0 ? gruß |
Re: Übersetzung Class MagneticWindow
Zitat:
Hinweis: Ich arbeite maximal mit Delphi 7, daher kann es gut sein, dass es in deiner Delphiversion die Möglichkeit der Wertzuweisung bei den Enum's gibt. Davon weiss ich aber nichts aus Ermangelung einer höheren Version. (Und ich weigere mich Dinge zu erlernen, die ich nicht praktisch anwenden kann...) |
Re: Übersetzung Class MagneticWindow
Zitat:
Es scheint so als wenn der compiler es annehmen würde. Kommt zumindest kein Fehler.
Delphi-Quellcode:
gruß
Type
eMsgWhen = Set Of (MSG_AFTER = 1, MSG_BEFORE = 2, MSG_BEFORE_AND_AFTER = MSG_AFTER Or MSG_BEFORE); // MSG_AFTER Message calls back after the original (previous) WndProc // MSG_BEFORE Message calls back before the original (previous) WndProc // MSG_BEFORE_AND_AFTER Message calls back before and after the original (previous) WndProc |
Re: Übersetzung Class MagneticWindow
Code:
Private Const ALL_MESSAGES As Long = -1 'All messages added or deleted
Private Const CODE_LEN As Long = 197 'Length of the machine code in bytes Private Const GWL_WNDPROC As Long = -4 'Get/SetWindow offset to the WndProc procedure address Private Const PATCH_04 As Long = 88 'Table B (before) address patch offset Private Const PATCH_05 As Long = 93 'Table B (before) entry count patch offset Private Const PATCH_08 As Long = 132 'Table A (after) address patch offset Private Const PATCH_09 As Long = 137 'Table A (after) entry count patch offset
Delphi-Quellcode:
Das dürfte wohl so stimmen, GWL_WNDPROC wird man wohl entfernen können
Const
ALL_MESSAGES : Integer = -1; //All messages added or deleted CODE_LEN : Integer = 197; //Length of the machine code in bytes GWL_WNDPROC : Integer = -4; //Get/SetWindow offset to the WndProc procedure address PATCH_04 : Integer = 88; //Table B (before) address patch offset PATCH_05 : Integer = 93; //Table B (before) entry count patch offset PATCH_08 : Integer = 132; //Table A (after) address patch offset PATCH_09 : Integer = 137; //Table A (after) entry count patch offset da die Const eigentlich in der Windows.pas vorhanden sein müßte.
Code:
Hier bin ich nicht sicher wie ich mit dem Variablen array verfahren soll.
Private Type tSubData 'Subclass data type
hwnd As Long 'Handle of the window being subclassed nAddrSub As Long 'The address of our new WndProc (allocated memory). nAddrOrig As Long 'The address of the pre-existing WndProc nMsgCntA As Long 'Msg after table entry count nMsgCntB As Long 'Msg before table entry count aMsgTblA() As Long 'Msg after table array aMsgTblB() As Long 'Msg Before table array End Type Edit: Denke so gehts!
Delphi-Quellcode:
gruß
Type TSubData = ^SubData; //Subclass data type
SubData = record hwnd : Integer; //Handle of the window being subclassed nAddrSub : Integer; //The address of our new WndProc (allocated memory). nAddrOrig : Integer; //The address of the pre-existing WndProc nMsgCntA : Integer; //Msg after table entry count nMsgCntB : Integer; //Msg before table entry count aMsgTblA : array [] of Integer; //Msg after table array aMsgTblB : array [] of Integer; //Msg Before table array End; |
Re: Übersetzung Class MagneticWindow
In der Standardeinstellung sind deine Konstanten nicht wirklich konstant: man kann ihnen Werte zuweisen. So sind es dann statische Variablen.
Warum definierst du einen Zeiger auf die Struktur? Im Normalfall wird mit Txxx eine Klasse oder eine Struktur gekennzeichnet. Einem Zeiger auf eine Struktur wird im Normalfall ein Pxxx anstatt einem Txxx vorangestellt. Und die [] bei dem Array kannst du getrost weglassen... |
Re: Übersetzung Class MagneticWindow
Zitat:
Delphi-Quellcode:
Mit den Zeiger habe ich mir abgeschaut um die Leute hier nicht zu nerven :oops:
Type PSubData = ^TSubData; //Subclass data type
TSubData = record hwnd : Integer; //Handle of the window being subclassed nAddrSub : Integer; //The address of our new WndProc (allocated memory). nAddrOrig : Integer; //The address of the pre-existing WndProc nMsgCntA : Integer; //Msg after table entry count nMsgCntB : Integer; //Msg before table entry count aMsgTblA : array of Integer; //Msg after table array aMsgTblB : array of Integer; //Msg Before table array End; Wird hier kein zeiger benötigt? Und wenn warum ? gruß |
Re: Übersetzung Class MagneticWindow
Wenn möglich sollte man wohl bei Integer- und Stringkonstanten keinen Typ angeben
Delphi-Quellcode:
Das hat vorallem den Vorteil, daß der Typ nicht schon da festgelegt ist und dieser dann anhand des Wertes und bei direkter Übergabe anhand des dortigen Types vom Compiler festgelegt wird.
const
abc = 123; def = 'xyz'; Speziell den String kann man dann auch als WideString/PWideChar übergeben, ohne daß es zu inkompatiblen Typen (AnsiString<>WideString und PAnsiChar<>PWideChar) kommt. |
Re: Übersetzung Class MagneticWindow
Zitat:
Hab sowieso meine problem mit der konvertierung von einigen variablen. Aber das kommt noch ;) Eile mit weile. werd dann mal die integer alle löschen ;) gruß |
Alle Zeitangaben in WEZ +1. Es ist jetzt 00:35 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