流程如下:
1、CreateProcess创建外部EXE进程2、获取指定区域的坐标
3、查找进程的主窗口
4、将外部程序移到指定区域
5、调用ShowWindow显示窗口
主程序如下:
handle=StartProcess("D:\\program tool\\SecureCRTPortable\\App\\SecureCRT\\SecureCRT.exe","");
UpdateData(TRUE);
HWND hwnd = NULL;
CRect rc;
//GetDlgItem(IDC_CRT)->GetClientRect(&rc);
GetDlgItem(IDC_CRT)->GetWindowRect(&rc);
int nWidth = rc.Width();
int nHeight = rc.Height();
ScreenToClient(rc);
while(!hwnd)
{
hwnd =::FindWindow("VanDyke Software - SecureCRT","not connected - SecureCRT");
}
if( hwnd)
{
LONG style=GetWindowLong(hwnd,GWL_STYLE);// 14CF 0000
style &=~WS_CAPTION;
style &=~WS_THICKFRAME;
//style |=WS_CHILD;
SetWindowLong(hwnd,GWL_STYLE,style);
::SetParent(hwnd,this->m_hWnd);
//::MoveWindow(hwnd, rc.left, rc.top, nWidth, nHeight, true); //将外部程序移到自自身窗口里
::SetWindowPos(hwnd,HWND_TOP, rc.left, rc.top, nWidth, nHeight, SWP_SHOWWINDOW |SWP_HIDEWINDOW );
// ::BringWindowToTop(hwnd);
//Invalidate();
//::UpdateWindow(hwnd);
::ShowWindow(hwnd,SW_SHOW);
}
一、启动外部程序
StarProcess函数如下:
HANDLE StartProcess(LPCTSTR program, LPCTSTR args)
{
HANDLE hProcess = NULL;
PROCESS_INFORMATION processInfo;
STARTUPINFO startupInfo;
::ZeroMemory(&startupInfo, sizeof(startupInfo));
startupInfo