Einzelnen Beitrag anzeigen

BassFan
(Gast)

n/a Beiträge
 
#12

Re: Probleme mit Threads und deren übergabe (wartezeit)

  Alt 20. Jul 2006, 20:51
Auch Moin

Zitat:
woher stammt denn

VisPlgHandle

in
Delphi-Quellcode:
function BASS_WINAMPVIS_GetAmpHwnd: DWORD; stdcall;

begin
    //repeat
    Result := VisPlgHandle;
    //until VisPlgHandle <> 0
end;
?

Zitat:
Ist das eine Funktion, wenn ja, was macht die genau?
Ist das eine Variable, wenn ja, wie wird die gefüllt?
VisPlgHandle ist das HWND der APPClass 'Winamp v1.x'

Bitte hier ist nochmal die ganze Routine welche das API-Fenster erstellt.

Delphi-Quellcode:
function WinampVisWin(VisInfo: PWinampVisInfo): HWND;
var
  WinAtom: TAtom;
  wClass: TWNDCLASSEX;
  Msg: TMsg;
  AppREC: Trect;
const
  AppClass = 'Winamp v1.x'; // Übergebe den ClassenNamen
  AppTitle = 'Winamp 5.2'; // Übergebe den Window Titel (Caption)
begin

  if VisPlgHandle <> 0 then // Erstelle das VisDummy Fenster
  begin
    try
      UnRegisterClass(AppClass, hInst);
      hInst := 0;
      VisInfo^.Init2 := False;
      VisPlgHandle := 0;
    except
      Messagebox(0,'Winamp Emulations Fenster konnte nicht erstellt werden',
                 'Fatal Error!!', MB_ICONERROR);
    end;
  end;

  hInst := GetModuleHandle(nil); // Hole die Apllikations Instanz

  with wClass do
  begin
    cbSize := sizeof(wClass);
    Style := CS_PARENTDC or CS_VREDRAW;
    lpfnWndProc := @WinampVisWndProc;
    cbClsExtra := 0;
    cbWndExtra := 0;
    hInstance := hInst;
    hIcon := 0;
    hCursor := LoadCursor(0, IDC_ARROW);
    hbrBackground := COLOR_BTNFACE + 1;
    lpszMenuName := nil;
    lpszClassName := AppClass;
    hIconSm := 0;
  end;

  // Classe registrieren. Bei erfolg das Window erstellen
  WinAtom := Windows.RegisterClassEx(wClass);

  if WinAtom <> 0 then
    Result := CreateWindowEx(0, AppClass, AppTitle,
      WS_POPUP, // Kein Frame, Unsichtbar
      0, 0, 275, 116, // x, y, width, height
      {parent} 0, 0, hInst, nil)
  else
    Result := 0;

  // Hwnd von der ausführenden Anwendung
  if AppParentHandle <> 0 then
  begin
    AmpHandle := 0;
    VisPlgHandle := Result;

    repeat
       AmpHandle := BASS_WINAMPVIS_GetAmpHwnd;
    until amphandle <> 0;
    // Den WindowRecord der Hauptanwendung in erfahrung bringen
    GetWindowRect(AppParentHandle, AppREC);
    // Das API-Fenster AppClass Winamp v1.x den Ausmaßen anpassen
    // wird verwendet wenn Plugin's eine Docking funktion anbieten.
    MoveWindow(VisPlgHandle, 0, 0, AppREC.Right - AppREC.Left, AppREC.Bottom - AppREC.Top, True);
  end
  else

  VisPlgHandle := Result;

  VisInfo^.WinHandle := VisPlgHandle;
  WinampVisExecute(Filename, Vismod, VismodCounter, VisPlgHandle);

  // ParentWindow den Plugins zuweisen
  VisInfo^.VisModule^.hwndParent := VisPlgHandle;
  // Plugin Initialisieren und ausführen
  VisInfo^.VisModule^.Init(VisInfo^.VisModule);
  // Das API-Fenster AppClass Winamp v1.x als ParentFenster in
  // die Hauptanwendung (AppParentHandle) verschieben
  SetParent(VisPlgHandle, AppParentHandle);

  // Das FensterHandle HWND des Plugins der Hauptanwendung
  // für weitere, dort ausgeführte funktionen übermitteln.
  Repeat
  PluginHandle := GetWindow(VisInfo^.VisModule^.hwndParent, GW_HWNDPREV);
  until PluginHandle <> 0;

  IsPlaying := 1;
  if IsPlaying > 0 then
    VisInfo^.Init2 := True
  else
    VisInfo^.Init2 := False;

  while (GetMessage(Msg, 0, 0, 0)) do
  begin
    TranslateMessage(Msg);
    DispatchMessage(Msg);
  end;

  VisInfo^.Init2 := False;

  UnregisterClass(AppClass, 0);

  W_RemoveHandle(DWORD(VisInfo));

  VisInfo^.VisModule^.Quit(VisInfo^.VisModule);

  DestroyWindow(VisInfo^.WinHandle);

  if (VisInfo^.Title <> nil) then
    StrDispose(VisInfo^.Title);

  FreeLibrary(VisInfo^.DllInstance);
  FreeMem(VisInfo);

  VisInfo^.WinHandle := 0;

  Result := 0;
end;
Habe es kommentiert damit man etwas besseren durchblick hat.

Gruß
  Mit Zitat antworten Zitat