//看一下吧:
function ChildProc(hWnd: HWND; Msg: UINT; wParam: WPARAM; lParam: LPARAM): LRESULT; stdcall;
begin
Result := CallWindowProc(Pointer(GetWindowLong(hWnd,GWL_USERDATA)),
hWnd, Msg, wParam, lParam);
Case Msg of
WM_NCACTIVATE:
if wParam >0 then SetWindowText(hWnd, PChar(FormatDateTime('HH:MM:SS',Now)));
end;
end;
function ClientProc(hWnd: HWND; Msg: UINT; wParam: WPARAM; lParam: LPARAM): LRESULT; stdcall;
var
h : Thandle;
begin
Result := CallWindowProc(Pointer(GetWindowLong(hWnd,GWL_USERDATA)),
hWnd, Msg, WPARAM, lParam);
Case Msg of
WM_MDICREATE:
with TMDICreateStruct(Pointer(lParam)^) do
begin
h := FindWindowEx(hWnd, 0, szClass, szTitle);
if h > 0 then
begin
SetWindowLong(h,GWL_USERDATA,GetWindowLong(h,GWL_WNDPROC));
SetWindowLong(h,GWL_WNDPROC,LongInt(@ChildProc));
end;
end;
end;
end;
procedure TMDIMain.FormCreate(Sender: TObject);
begin
SetWindowLong(ClientHandle,GWL_USERDATA,GetWindowLong(ClientHandle,GWL_WNDPROC));
SetWindowLong(ClientHandle,GWL_WNDPROC,LongInt(@ClientProc));
end;