根据杜宝的方法,我做了一些修改,但是还是没有通过,主窗口会失去焦点。
procedure TForm1.OpenDialog1Show(Sender: TObject);
var
aHandle : HWND;
astyle: integer;
begin
aHandle := FindWindow(nil, '打开一个文件');
if aHandle <> 0 then
begin
astyle := getwindowlong(ahandle, GWL_STYLE);
astyle := astyle and not ws_caption and WS_CHILD and not WS_DLGFRAME and not WS_SIZEBOX and not WS_POPUPWINDOW;
setwindowlong(ahandle, gwl_style, $56000000); //style 根据 tpanel的样式读出(from spy++)
setwindowlong(ahandle, gwl_exstyle, $00010000);
movewindow(ahandle, 0, 0, 400, 300, false);
Windows.SetParent(aHandle, Handle);
end;
end;