怎样才可以把一个 cmd.exe 打开的窗口 放在我的子窗体内?

解决方案 »

  1.   

    参考以下就可以做到://将查找对话框放入自己的窗口中
    procedure TForm1.FormCreate(Sender: TObject);//只能在FormCreate事件中实现
    var
       h:thandle;
       rec:trect;
    begin
       shellexecute(form1.Handle,'find','c:\',nil,nil,sw_shownormal);//改为打开你的窗口或者删除
       sleep(300);
       h:=findwindow(nil,'搜索结果');//改为你的窗口标题
       GetWindowRect(h,rec);
       SetWindowPos(h,HWND_TOP,0,-5-(GetSystemMetrics(SM_CYCAPTION)+GetSystemMetrics(SM_CYBORDER)),ScrollBox1.Width,ScrollBox1.Height,SWP_NOSIZE or SWP_SHOWWINDOW);
       windows.SetParent(h,ScrollBox1.Handle);
       ScrollBox1.HorzScrollBar.Range :=rec.Right -rec.Left ;
       ScrollBox1.VertScrollBar.Range :=rec.Bottom -rec.Top ;
    end;