AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

Von C nach D (elphi) - Äh wie ?

Ein Thema von turboPASCAL · begonnen am 8. Okt 2007 · letzter Beitrag vom 8. Okt 2007
Antwort Antwort
Benutzerbild von turboPASCAL
turboPASCAL

Registriert seit: 8. Mai 2005
Ort: Sondershausen
4.274 Beiträge
 
Delphi 6 Personal
 
#1

Von C nach D (elphi) - Äh wie ?

  Alt 8. Okt 2007, 17:04
Hi,

isch habe da so ein kleines Problemschen. Ich habe mit mal das Winamp Plugin SDK
angeschaut. Soweit so gut, aber an diesen Stellen komm ich nicht weiter:

Code:
void config(struct winampVisModule *this_mod)
{
   MessageBox(this_mod->hwndParent,"This module is Copyright (c) 1997-1998, Justin Frankel/Nullsoft\n"
                           "-- This is just a demonstration module, it really isn't\n"
                           "  supposed to be enjoyable --","Configuration",MB_OK);
}

embedWindowState myWindowState; // <--<<< //

winampVisModule *g_mod = NULL;

int width;
int height;

// initialization. Registers our window class, creates our window, etc. Again, this one works for
// both modules, but you could make init1() and init2()...
// returns 0 on success, 1 on failure.
int init(struct winampVisModule *this_mod)
{
  int styles;
  HWND parent = NULL;
  HWND (*e)(embedWindowState *v); // <--<<< //

   width = (this_mod == &mod3)?256:288; // width and height are the same for mod1 and mod2,
   height = (this_mod == &mod3)?32:256; // but mod3 is shaped differently
 // >>>--> //

  g_mod = this_mod;

   config_read(this_mod);

  // uncomment this line if your plugin draws to the screen using directx OVERLAY mode
  // myWindowState.flags |= EMBED_FLAGS_NOTRANSPARENCY;
 
  myWindowState.r.left = config_x; // <--<<< //
  myWindowState.r.top = config_y;
  myWindowState.r.right = config_x + width;
  myWindowState.r.bottom = config_y + height;
     
  // <--<<< //
  *(void**)&e = (void *)SendMessage(this_mod->hwndParent,WM_WA_IPC,(LPARAM)0,IPC_GET_EMBEDIF);
 // >>>--> //

  if (!e)
  {
      MessageBox(this_mod->hwndParent,"This plugin requires Winamp 5.0+","blah",MB_OK);
      return 1;
  }

  parent = e(&myWindowState); // <--<<< // 

  SetWindowText(myWindowState.me, this_mod->description); // set our window title
   
   {   // Register our window class
      WNDCLASS wc;
      memset(&wc,0,sizeof(wc));
      wc.lpfnWndProc = WndProc;            // our window procedure
      wc.hInstance = this_mod->hDllInstance;   // hInstance of DLL
      wc.lpszClassName = szAppName;         // our window class name
   
      if (!RegisterClass(&wc))
      {
         MessageBox(this_mod->hwndParent,"Error registering window class","blah",MB_OK);
         return 1;
      }
   }

  styles = WS_VISIBLE|WS_CHILDWINDOW|WS_OVERLAPPED|WS_CLIPCHILDREN|WS_CLIPSIBLINGS;


   hMainWnd = CreateWindowEx(
      0,   // these exstyles put a nice small frame,
                                 // but also a button in the taskbar
      szAppName,                     // our window class name
      NULL,            // no title, we're a child
      styles,                               // do not make the window visible
      config_x,config_y,               // screen position (read from config)
      width,height,                  // width & height of window (need to adjust client area later)
      parent,            // parent window (winamp main window)
      NULL,                        // no menu
      this_mod->hDllInstance,            // hInstance of DLL
      0); // no window creation data
Matti
Meine Software-Projekte - Homepage - Grüße vom Rüsselmops -Mops Mopser
  Mit Zitat antworten Zitat
Apollonius

Registriert seit: 16. Apr 2007
2.325 Beiträge
 
Turbo Delphi für Win32
 
#2

Re: Von C nach D (elphi) - Äh wie ?

  Alt 8. Okt 2007, 17:22
Ich übersetze die markierten Stellen einfach mal nach Delphi.
Code:
embedWindowState myWindowState;
var myWindowState: embedWindowState; //globale Variable
Code:
HWND (*e)(embedWindowState *v); //Funktionszeiger in C sind etwas schwierig
var e: function(v: pEmbedWindowState): hwnd;
Code:
g_mod = this_mod;
 g_mod:=this_mod
Code:
myWindowState.r.left = config_x; //Wo liegt das Problem?
Code:
*(void**)&e = (void *)SendMessage(this_mod->hwndParent,WM_WA_IPC,(LPARAM)0,IPC_GET_EMBEDIF); //köstlich!
PPointer(@@e)^:=Pointer(SendMessage(this_mod^.hwndParent, WM_WA_IPC, LPARAM(0), IPC_GET_EMBEDIF)) Das geht auch einfacher als
Pointer(e):=Pointer(SendMessage(this_mod^.hwndParent, WM_WA_IPC, LPARAM(0), IPC_GET_EMBEDIF))
Code:
parent = e(&myWindowState);
Parent:=e(@MyWindowState)
Wer erweist der Welt einen Dienst und findet ein gutes Synonym für "Pointer"?
"An interface pointer is a pointer to a pointer. This pointer points to an array of pointers, each of which points to an interface function."
  Mit Zitat antworten Zitat
Benutzerbild von turboPASCAL
turboPASCAL

Registriert seit: 8. Mai 2005
Ort: Sondershausen
4.274 Beiträge
 
Delphi 6 Personal
 
#3

Re: Von C nach D (elphi) - Äh wie ?

  Alt 8. Okt 2007, 18:02
Vielen Dank.

Code:
*(void**)&e = (void *)SendMessage(...
Solche Stellen find ich immer toll.

Code:
myWindowState.r.left = config_x; //Wo liegt das Problem?
Ich habe k.Ahnung wo die Leutchen den Record her haben.
Matti
Meine Software-Projekte - Homepage - Grüße vom Rüsselmops -Mops Mopser
  Mit Zitat antworten Zitat
Muetze1
(Gast)

n/a Beiträge
 
#4

Re: Von C nach D (elphi) - Äh wie ?

  Alt 8. Okt 2007, 18:06
Zitat von turboPASCAL:
Code:
myWindowState.r.left = config_x; //Wo liegt das Problem?
Ich habe k.Ahnung wo die Leutchen den Record her haben.
Na myWindowState ist doch vom Typ embedWindowState, somit such nach dessen Deklaration...
  Mit Zitat antworten Zitat
Benutzerbild von turboPASCAL
turboPASCAL

Registriert seit: 8. Mai 2005
Ort: Sondershausen
4.274 Beiträge
 
Delphi 6 Personal
 
#5

Re: Von C nach D (elphi) - Äh wie ?

  Alt 8. Okt 2007, 18:10
Ich habe in die falsche Headerdatei geschaut.

Code:
typedef struct
{
  HWND me; //hwnd of the window

  int flags;

  RECT r;

  void *user_ptr; // for application use

  int extra_data[64]; // for internal winamp use
} embedWindowState;
... ist ein Fall von Selberschult.
Matti
Meine Software-Projekte - Homepage - Grüße vom Rüsselmops -Mops Mopser
  Mit Zitat antworten Zitat
Antwort Antwort


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 05:55 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