Actually, you're right in what you say. I accidently passed the HWND of the MDI window to the function, sorry.
Either way, it still doesn't work. GetTopWindow(mwnd) now only returns one single number, no matter which window is the active one.
function getactivehwnd(mwnd,awnd:hwnd;data,parms:pchar;show,nopause:boolean):integer;stdcall;
begin
strcopy(data,pchar(inttostr(GetTopWindow(mwnd))));
result:=3;
end;