Ver Mensaje Individual
  #11  
Antiguo 11-06-2015
Avatar de duilioisola
[duilioisola] duilioisola is offline
Miembro Premium
 
Registrado: ago 2007
Ubicación: Barcelona, España
Posts: 1.735
Reputación: 20
duilioisola Es un diamante en brutoduilioisola Es un diamante en brutoduilioisola Es un diamante en bruto
Si quieres crear el Panel de forma dinámica puedes hacerlo así:

Código Delphi [-]
type
  TFMPruebas = class(TForm)
...
     procedure PNLEjecutarNotepadResize(Sender: TObject);
  private
     { Private declarations }
     fNotepadHandle : HWND;
...
  public
     { Public declarations }
...
  end;

procedure TFMPruebas.BEjecutarNotepadClick(Sender: TObject);
var
  Rec: TShellExecuteInfo;
  Panel : TPanel;
const
  AVerb = 'open';
  AParams = '';
  AFileName = 'Notepad.exe';
  ADir = '';
begin
  // Crear panel en forma dinamica
  Panel := TPanel.Create(Self);
  with Panel do
  begin
     // Debe estar sobre el Tabsheet
     Parent := TabSheet1;
     // Alineado al total del espacio disponible
     Align := alClient;
     // Cuando cambie de tamaño debe ejecutar esto para ajustar el tamaño del programa ejecutado dentro
     OnResize := PNLEjecutarNotepadResize;
  end;

  FillChar(Rec, SizeOf(Rec), #0);

  Rec.cbSize       := SizeOf(Rec);
  Rec.fMask        := SEE_MASK_NOCLOSEPROCESS;
  Rec.lpVerb       := PChar( AVerb );
  Rec.lpFile       := PChar( AfileName );
  Rec.lpParameters := PChar( AParams );
  Rec.lpDirectory  := PChar( Adir );
  Rec.nShow        := SW_HIDE;

  ShellExecuteEx(@Rec);
  WaitForInputIdle(Rec.hProcess, 5000);

  fNotepadHandle := Windows.FindWindow( 'Notepad', nil );
  Windows.SetParent( fNotepadHandle, Panel.Handle );

  // Put the focus on notepad
  Windows.SetFocus( fNotepadHandle );

  Resize;
  ShowWindow(fNotepadHandle, SW_SHOW);
end;

procedure TFMPruebas.PNLEjecutarNotepadResize(Sender: TObject);
begin
  if IsWindow(fNotepadHandle) then begin
    SetWindowPos(fNotepadHandle, 0, 0, 0, TPanel(Sender).ClientWidth, TPanel(Sender).ClientHeight,
      SWP_ASYNCWINDOWPOS);
  end;
end;
Responder Con Cita