![]() |
Powerbasic 1 zeilen problem
habe ein problem mit einer zeile in dieser Funktion
wenn jemand sich in PB auskennt .. Wie muss ich die in Delphi interpretieren.
Code:
um diese zeile geht es
'// Send/recept message to/from plugin
Function BBP_Plugin(ByRef BBP As BBPLUGIN) As Long LOCAL hProc AS DWORD, nRet AS LONG nRet = %BBP_ERROR If glRC Then hProc = BBP_ProcHandle(0, 0): IF hProc THEN CALL DWORD hProc USING BBP_Plugin(BBP) TO nRet End If FUNCTION = nRet End Function
Code:
gruss Emil
BBP_ProcHandle(0, 0): IF hProc THEN CALL DWORD hProc USING BBP_Plugin(BBP) TO nRet
|
Re: Powerbasic 1 zeilen problem
Hallo Emil,
irritiert dich der Doppelpunkt? In PowerBasic (u.a.) können mehrere Statements in eine Zeile geschrieben werden, wenn man sie mit dem Statement Separator (Doppelpunkt) voneinander trennt. Freundliche Grüße |
Re: Powerbasic 1 zeilen problem
Zitat:
Nein eigentlich nicht denn das ist mir unter VB bekannt Was mich irritiert ist diese zeile (sorry) -->
Delphi-Quellcode:
glRC : HGLRC;
hProc : LongInt; BBP_ProcHandle ist ne Function stellt kein problem dar. BBP_Plugin(BBP) das auch nicht.
Code:
If glRC <> 0 Then
hProc := BBP_ProcHandle(0, 0); if hProc <> 0 then --> CALL DWORD hProc USING BBP_Plugin(BBP) TO nRet CALL DWORD hProc USING und das ganze nach nRet das irritiert mich. Meine vermutung! Führe BBP_Plugin(BBP) oder nRet aus Wenn dann in welchen zusammen hang wie wird geprüft ob nun die Funktion oder aber nRet maßgeblich ist. EDIT: Auch ist die Schnittstelle etwas unverständlich.. Habe mich in dem Forum angemeldet allerdings kann mir da wegen meinen schlechten Englisch kaum jemand helfen..
Code:
Übersetzung ansicht kein problem (soweit fertig)
//Yes, BassBox has a plugin interface, and you can find the full history of the project there:
//http://www.jose.it-berater.org/smfforum/index.php?topic=1364.0 //Each of the BassBox plugin in an independant plain Win32 DLL that does use one single exported function, //that works like a standard SDK Window Proc. '// The main exported plugin's function would be bbProc, like this: FUNCTION BBProc ALIAS "BBProc" (BYREF BBP AS BBPLUGIN) EXPORT AS LONG LOCAL nRet AS LONG nRet = %BBP_SUCCESS SELECT CASE LONG BBP.Msg CASE %BBP_RENDER '// Draw the scene using BBP.LeftPeak and BBP.RightPeak CASE %BBP_CREATE '// Retrieve plugin details BBP.Title = "My BB plugin" BBP.Author = "My Name" BBP.Version = MAKDWD(1, 0) '// Version 1.0" BBP.RenderTo = %BBP_OPENGL '// or %BBP_GDIPLUS, or %BBP_DIRECTX CASE %BBP_INIT '// Do your code initialisation there CASE %BBP_SIZE '// The size of the view port has changed. CASE %BBP_KEYBOARD '// Handle all Windows keyboard messages there Msg = BBP.WinMsg wParam = BBP.wParam lParam = BBP.lParam CASE %BBP_MOUSE '// Handle all Windows mouse messages there Msg = BBP.WinMsg wParam = BBP.wParam lParam = BBP.lParam CASE %BBP_DESTROY '// Free up your resources there CASE ELSE nRet = %BBP_ERROR END SELECT FUNCTION = nRet END FUNCTION //And to communicate with the plugin.dll, the main EXE uses this structure type: TYPE BBPLUGIN '// 256 bytes Msg AS LONG '// The plugin's message (see above constant list). ParentWindow AS LONG '// The parent window handle. DC AS LONG '// The parent window DC (while in play mode). RC AS LONG '// The parent OpenGL RC (while in play mode). Lpeak AS WORD '// The left audio channel peak value (while in play mode). Rpeak AS WORD '// The right audio channel peak value (while in play mode). Title AS ASCIIZ * 32 '// Plugin's name or title. Author AS ASCIIZ * 64 '// Plugin's author name. Version AS DWORD '// LOWRD major, HIWRD minor. RenderTo AS LONG '// %BBP_GDIPLUS, %BBP_OPENGL, %BBP_DIRECTX. BackARGB AS LONG '// Default ARGB color background. FFTdata AS DWORD '// DWORD pointer to the FFT() AS SINGLE array. FFTsize AS WORD '// Size of the FFT array. WinMsg AS LONG '// True Windows message. wParam AS LONG '// wParam lParam AS LONG '// lParam WIMdata AS DWORD '// DWORD pointer to the wave MM_WIM_DATA. MediaLength AS DWORD '// Media length. MediaPos AS DWORD '// Media pos. Reserved AS ASCIIZ * 98 '// Reserved for future extension. END TYPE //The name of the procedure being used in the main EXE to communicate with the active plugin is BBP_Plugin (BYREF BBP AS BBBPLUGIN) //In BassBox, all the plugins are closely tied to the BassChannelGetLevel API to perform real time audio visualization. Nur wo gehts nach außen und wo wird was empfangen...(von der Winproc abgesehen) gruss Emil |
Re: Powerbasic 1 zeilen problem
Code:
So wird in PowerBasic eine DLL-Funktion dynamisch aufgerufen. in hProc steht die Adresse (GetProcAddress()) der Funktion, BBP_Plugin ist der function prototype und BBP soll als Argument übergeben werden. Der Rückgabewert der Funktion soll in nRet gespeichert werden.
--> CALL DWORD hProc USING BBP_Plugin(BBP) TO nRet
|
Re: Powerbasic 1 zeilen problem
Zitat:
gruss Emil |
Re: Powerbasic 1 zeilen problem
Komme trotzdem irgenwie nicht klar
BBP zeigt auf die Struct(record) PBBPlugin Das handle ist ja bekannt kann es also direkt übergeben.
Delphi-Quellcode:
function BBP_Plugin(BBP : PBBPLUGIN; handle: HVIS): LongInt;
Ich übergebe jetzt der BBP.MSG den wert BBP_CREATE Zitat:
Delphi-Quellcode:
weiss nun nicht wie ich BBP_Plugin(BBP) innerhalb BBP_Plugin aufrufen soll das hätte doch einen loop zur folge.
BassBoxInfo.Msg := BBP_CREATE;
Es sollte doch zumindest ein export oder ein cdecl vorhanden sein oder ? Schon ein bißchen unverständlich das ganze. Was mir also fehlt ist die ein und ausgabe, kommunikation mit der DLL Das andere werde ich auf die reihe bekommen da PowerBasik doch VB sehr ähnlich ist. Auch ist mir unverständlich wie die neuen Daten des records von der DLL übergeben werden also Titel, name, Version .. usw. In nRet steht ja dann nur ob der aufruf erfolgreich war BBP_SUCCESS = 0 oder BBP_ERROR = -1 gruss Emil |
Re: Powerbasic 1 zeilen problem
Hallo Emil,
ich weiß nicht wo du einen rekursiven Aufruf von BBP_Plugin() siehst. Irgendwo musst du etwas ähnliches wie das hier gemacht haben:
Delphi-Quellcode:
Der Code aus deinem Beitrag #1 kapselt einfach den dynamischen Aufruf der DLL-Funktion:
const
LIB_NAME = '?'; type TBbpPluginRec = record Msg: Integer; ParentWindow: Integer; DC: Integer; // ... end; TBbpPluginFunc = function (var bbp: TBbpPluginRec): Integer; var BbpPluginFunc: TBbpPluginFunc; hLib: THandle; begin // hLib := LoadLibrary(LIB_NAME); // error check ... @BbpPluginFunc := GetProcAddress(hLib, 'BBP_Plugin'); // ... end
Delphi-Quellcode:
Die Werte für Author, Title etc. werden im Record bbp zurückgegeben.
function BBP_Plugin(var bbp: TBbpPluginRec): Integer;
begin // ... Result := BbpPluginFunc(bbp); end; Gute Nacht |
Re: Powerbasic 1 zeilen problem
Liste der Anhänge anzeigen (Anzahl: 1)
Jo so habe ich es gemacht ;)
Delphi-Quellcode:
andere namen aber egal...
TBbpPluginFunc = function (var bbp: TBbpPluginRec): Integer;
Der unterschied bei mir kein "var" vor bbp(deshalb keine rückgabe) und ein angehängtes stdcall
Delphi-Quellcode:
ohne stdcall bekomme ich ein BBP_ERROR = -1;
TBbpPluginFunc = function (var bbp: TBbpPluginRec): Integer; stdcall;
mit bekomme ich als rückgabe BBP_SUCCESS = 0; sobald aber BBP_Plugin verlassen wird kracht es muss noch nachsehn warum EDIT: Sieht danach aus das der im record definierte Titel und Author das problem verursacht ursprünglich definiert
Delphi-Quellcode:
habe an stelle dessen string[32] genommen dann kracht es
Title AS ASCIIZ * 32 '// Plugin's name or title.
Author AS ASCIIZ * 64 '// Plugin's author name. nehme ich PChar dann läuft es durch der text ist dann aber "nil" steht nix drin. Muss noch schaun was ich bei den nullterminierten ASCIIZ in Delphi nehmen kann EDIT2: verbunden bin ich jetzt aber die strings machen immer noch probleme weiss nicht was ich da nehmen soll. aktuelle abfrage
Delphi-Quellcode:
Siehe Pic ..
function BASS_BASSBOXVIS_GetName(handle: HVIS): PChar; stdcall;
var nRet : Integer; begin Result := nil; // Initialize BassBoxInfo BassBoxInfo := PBbpPluginRec(handle); // check is valid handle if (not BB_ValidHandle(handle)) then begin BassFuncs^.SetError(BASS_ERROR_HANDLE); Exit; end; // send BBP_CREATE Retrieve Title, Name, Version, Render mode. BassBoxInfo.Msg := BBP_CREATE; nRet := BBP_Plugin(BassBoxInfo^); if nRet = BBP_ERROR then begin FreeLibrary(handle); FreeMem(BassBoxInfo); BassFuncs^.SetError(BASS_ERROR_START); Exit; end else BassFuncs^.SetError(BASS_OK); Result := PChar(Length(BassBoxInfo^.Title)); end; gruss Emil |
Re: Powerbasic 1 zeilen problem
Moin Emil,
ob stdcall oder nicht, das kannst nur du wissen, da ich die DLL nicht kenne. Bei den Strings musst du wissen, dass "Title AS ASCIIZ * 32" in Delphi weder mit string noch mit string[32] identisch ist. Es ist einfach ein "Title: Array [0..31] of Char", auf den du mit String(Title) zugreifst. Schönen Sonntag |
Re: Powerbasic 1 zeilen problem
Zitat:
Zitat:
Auch dir einen schönen Sonntag gruss Emil PS: Dann doch was länger als nur eine Zeile ;) ups.. |
Alle Zeitangaben in WEZ +1. Es ist jetzt 11:09 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-2025 by Thomas Breitkreuz