Open an application inside a TForm at a predefined position (Views: 29)
Problem/Question/Abstract: How do I open an executable in a determined form's area? Example: Open an executable and show it on the left forms part with a size of 400 x 300. Answer: This works for me. Keep in mind that some apps have their startup settings set somewhere which may override the Startup structure you pass. procedure TForm1.Button1Click(Sender: TObject); var StartupInfo: TStartupInfo; ProcessInfo: TProcessInformation; begin FillChar(StartupInfo, Sizeof(StartupInfo), #0); StartupInfo.cb := Sizeof(StartupInfo); StartupInfo.dwFlags := STARTF_USEPOSITION or STARTF_USESIZE; StartupInfo.wShowWindow := SW_SHOWNORMAL; StartupInfo.dwX := Left; StartupInfo.dwY := Top; StartupInfo.dwXSize := 400; StartupInfo.dwYSize := 300; CreateProcess(nil, 'yourapp.exe', nil, nil, false, CREATE_NEW_CONSOLE or NORMAL_PRIORITY_CLASS, nil, nil, StartupInfo, ProcessInfo); end; |