private void FlashRecovery_Resize(object sender, EventArgs e) { Refresh(); //通知业务进程改变窗体大小 CurGlobals.SENDMESSAGETRANSFERSTRUCT temp = new CurGlobals.SENDMESSAGETRANSFERSTRUCT(); temp.dwData = this.Handle; //设置业务进程的窗体大小 string tempSize = $"{this.exeTabControl.Width - 5},{this.exeTabControl.Height - 5}".PadLeft(20, '0'); byte[] arr = System.Text.Encoding.Default.GetBytes(tempSize); //参数的长度 temp.cbData = arr.Length + 1; //业务进程窗体大小参数 temp.lpData = tempSize; //向每个进程发消息 foreach (Process p in m_AppProcess) { CurGlobals.SendMessage(p.MainWindowHandle, WM_COPYDATA, IntPtr.Zero, ref temp); } }
//将指定的程序嵌入指定的控件 private void EmbedProcess(Process app, Control con, int flag) { if (app == null || app.MainWindowHandle == IntPtr.Zero || con == null) { return; } //设置窗体展示方式 CurGlobals.ShowWindow(app.MainWindowHandle, (short)5); //设置父窗体 CurGlobals.SetParent(app.MainWindowHandle, con.Handle); SetWindowLong(new HandleRef(this, app.MainWindowHandle), GWL_STYLE, WS_VISIBLE); CurGlobals.SendMessage(app.MainWindowHandle, WM_SETTEXT, IntPtr.Zero, strGUID); CurGlobals.MoveWindow(app.MainWindowHandle, 0, 0, con.Width, con.Height, true); if (flag != -1) { CurGlobals.SENDMESSAGETRANSFERSTRUCT temp = new CurGlobals.SENDMESSAGETRANSFERSTRUCT(); temp.cbData = _argument; temp.dwData = Handle; CurGlobals.SendMessage(app.MainWindowHandle, WM_COPYDATA, IntPtr.Zero, ref temp); } }