type TAPIWndProc =
function(WndHWND: HWnd; uMsg: UInt; wParam: WParam; lParam: LParam): LResult;
stdcall;
function NewWndProc(WndHWND: HWnd; uMsg: UInt; wParam: WParam; lParam: LParam): LResult;
stdcall;
var Image:TImage32;
OldProc: TAPIWndProc;
i,k:integer;
len:integer;
s:PChar;
FwdMsg: TMessage;
begin
for i := 0
to 5
do
if (Mixer.Images[i].Handle = WndHWND)
then // Instanz suchen
begin
Image := Mixer.Images[i];
OldProc := Pointer(@Mixer.OldWndProcs[i]);
break;
end;
if (uMsg = WM_DROPFILES)
then //Bild laden
begin
i := Image.Tag;
len := DragQueryFile(wParam,0,
nil,0) +1;
s := StrAlloc(len);
DragQueryFile(wParam,0,s,len);
Mixer.pbms[i].Free;
Mixer.pbms[i] := TPBM.Create(s);
Image.Bitmap.Assign(Mixer.pbms[i].Draw());
StrDispose(s);
end;
Result := OldProc(WndHWND,uMsg,wParam,lParam);
// Das ganze an die alte WndProc übergeben
end;
procedure TMixer.FormCreate(Sender: TObject);
var i:integer;
begin
Images[0] := ImageLeft;
Images[1] := ImageRight;
Images[2] := ImageResult;
Images[3] := Dump1;
Images[4] := Dump2;
Images[5] := Dump3;
for i := 0
to 5
do
begin
Images[i].HandleNeeded;
//Handle erzeugen
OldWndProcs[i] := Pointer(GetWindowLong(Images[i].Handle,GWL_WNDPROC));
//Alte Wndproc speichern
SetWindowLong(Images[i].Handle,GWL_WNDPROC,Integer(@NewWndProc));
//Neue Wndproc injizieren
DragAcceptFiles(Images[i].Handle,true);
//Und hier der Zweck des ganzen Brimboriums!
end;
end;