QString strExt = "Notepad";
ui.setupUi(this);
WId parent_HWND = winId();
setProperty("_q_embedded_native_parent_handle", QVariant(parent_HWND));
QString cmd = "C:/Windows/system32/" + strExt + ".exe";
STARTUPINFO si = { sizeof(si) };
PROCESS_INFORMATION pi;
si.dwFlags = STARTF_USESHOWWINDOW;
si.wShowWindow = true;
bool bRet = CreateProcess(
NULL,
(LPWSTR)cmd.toStdWString().c_str(),
NULL,
NULL,
FALSE,
CREATE_NEW_CONSOLE,
NULL,
NULL, &si, &pi);
Sleep(1000);
HWND hhd = FindWindow(L"Notepad", NULL);
QString Name = strExt;
HWND SimpackWnd = hhd;
if (SimpackWnd != NULL)
{
RECT rc;
GetClientRect((HWND)(this->winId()), &rc);
LONG style = ::GetWindowLong(SimpackWnd, GWL_STYLE);
style &= ~WS_CLIPSIBLINGS;
::SetWindowLong(SimpackWnd, GWL_STYLE, style);
::SetParent(SimpackWnd, (HWND)(this->winId()));
::SetWindowPos(SimpackWnd, HWND_TOP, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top, SWP_SHOWWINDOW | SWP_FRAMECHANGED);
}