Ir al contenido


Foto

shellexecute


Mejor respuesta escafandra , 02 diciembre 2018 - 08:54

Acabo de llegar a casa y he adaptado el código para Berlin. El problema es el UNICODE de la función ExecuteAsChild, sin embargo ExecuteAsChild2 no requiere cambios. Recordar que ambas funciones realizan exactamente lo mismo y están puestas para que cada uno elija la forma que le guste más.
 
Este sería el código completo en un proyecto partiendo de cero en Berlin:


delphi
  1. unit Unit1;
  2.  
  3. interface
  4.  
  5. uses
  6.   Winapi.Windows, Winapi.Messages, Winapi.ShellApi, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  7.   Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Vcl.ExtCtrls;
  8.  
  9. type
  10.   TForm2 = class(TForm)
  11.     Button2: TButton;
  12.     Button1: TButton;
  13.     Panel1: TPanel;
  14.     procedure Button1Click(Sender: TObject);
  15.     procedure Button2Click(Sender: TObject);
  16.   private
  17.     ChildHandle: THandle;
  18.   public
  19.     { Public declarations }
  20.   end;
  21.  
  22. var
  23.   Form2: TForm2;
  24.  
  25. implementation
  26.  
  27. {$R *.dfm}
  28.  
  29. function GetWindowFromPId(PId: DWORD): THandle;
  30. type
  31.   TWinParam = record
  32.     Handle: THandle;
  33.     PId: DWORD;
  34.   end;
  35.   PWinParam = ^TWinParam;
  36. var
  37.   WinParam: TWinParam;
  38.  
  39.   function EnumWindowsProc(Handle: Thandle; lParam: LPARAM): BOOL; stdcall;
  40.   var
  41.     PId: DWORD;
  42.   begin
  43.     Result:= true;
  44.     PId:= 0;
  45.     GetWindowThreadProcessId(Handle, PId);
  46.     if PWinParam(lParam).PId = PId then
  47.     begin
  48.       PWinParam(lParam).Handle:= Handle;
  49.       Result:= false;
  50.     end;
  51.   end;
  52.  
  53. begin
  54.   WinParam.Handle:= 0;
  55.   WinParam.PId:= PId;
  56.   EnumWindows(@EnumWindowsProc, LPARAM(@WinParam));
  57.   repeat
  58.     Result:= WinParam.Handle;
  59.     WinParam.Handle:= Winapi.Windows.GetParent(Result);
  60.   until WinParam.Handle = 0;
  61. end;
  62.  
  63. function ExecuteAsChild(CommandLine: AnsiString; Handle: THandle): THandle;
  64. var
  65.   SI: TStartupInfoA;
  66.   PI: TProcessInformation;
  67.   CR: TRect;
  68. begin
  69.   ZeroMemory(@SI, sizeof(SI));
  70.   SI.cb:= sizeof(sizeof(SI));
  71.   SI.dwFlags:=  STARTF_USESHOWWINDOW or STARTF_USEPOSITION or STARTF_USESIZE;
  72.   Result:= 0;
  73.   if CreateProcessA(nil, PAnsiCHAR(CommandLine), nil, nil, false, 0, nil, nil, SI, PI) then
  74.   begin
  75.     WaitForInputIdle(PI.hProcess, 10000);
  76.     Result:= GetWindowFromPId(PI.dwProcessId);
  77.     Winapi.Windows.SetParent(Result, Handle);
  78.     GetClientRect(Handle, CR);
  79.     SetWindowLong(Result, GWL_STYLE, WS_BORDER);
  80.     SetWindowPos(Result, 0, 0, 0, CR.Right-CR.Left, CR.Bottom-CR.Top, SWP_SHOWWINDOW);
  81.     CloseHandle(PI.hProcess);
  82.     CloseHandle(PI.hThread);
  83.   end;
  84. end;
  85.  
  86. function ExecuteAsChild2(ExeFile: String; Handle: THandle): THandle;
  87. var
  88.   SI: TShellExecuteInfo;
  89.   CR: TRect;
  90. begin
  91.   ZeroMemory(@SI, sizeof(SI));
  92.  
  93.   SI.cbSize:= SizeOf(SI);
  94.   SI.fMask:=  SEE_MASK_NOCLOSEPROCESS;
  95.   SI.lpVerb:= 'Open';
  96.   SI.lpFile:= PChar(ExeFile);
  97.   SI.nShow:=  SW_HIDE;
  98.  
  99.   Result:= 0;
  100.   if ShellExecuteEx(@SI) then
  101.   begin
  102.     WaitForInputIdle(SI.hProcess, 5000);
  103.     Result:= GetWindowFromPId(GetProcessId(SI.hProcess));
  104.     Winapi.Windows.SetParent(Result, Handle );
  105.     Winapi.Windows.GetClientRect(Handle, CR);
  106.     SetWindowLong(Result, GWL_STYLE, WS_BORDER);
  107.     SetWindowPos(Result, 0, 0, 0, CR.Right-CR.Left, CR.Bottom-CR.Top, SWP_SHOWWINDOW);
  108.     CloseHandle(SI.hProcess);
  109.   end;
  110. end;
  111.  
  112.  
  113. procedure TForm2.Button1Click(Sender: TObject);
  114. begin
  115.   ChildHandle:= ExecuteAsChild('Notepad.exe', Panel1.Handle);
  116. end;
  117.  
  118. procedure TForm2.Button2Click(Sender: TObject);
  119. begin
  120.   Winapi.Windows.PostMessage(ChildHandle, WM_QUIT, 0, 0);
  121. end;
  122.  
  123. end.

En la imagen se ejecuta el notepad.exe dentro de un TPanel:
 
c6af221f93d1c37b920a05819d67bb49o.gif
 
Subo el proyecto.
 
Saludos,

Ir al mensaje completo


  • Por favor identifícate para responder
16 respuestas en este tema

#1 Caral

Caral

    Advanced Member

  • Moderador
  • PipPipPip
  • 4.266 mensajes
  • LocationCosta Rica

Escrito 30 noviembre 2018 - 02:21

Hola a todos

Tengo un programa (exe) que lo que hace es:

1 ejecutarse

2 abrir un opendialog (buscador de archivos y carpetas)

3 buscar (manualmente) un archivo

4 dicho archivo al abrirse pide una clave

5 dar aceptar

6 se cierra.

Pregunto:

Como puedo manejar esos eventos desde otro programa en delphi

1 ejecutarlo desde mi programa en delphi

2 crear todos esos 6  pasos desde mi programa en delphi

3 cerrar ese programa desde mi programa en delphi

Desconozco el sistema en que se hizo ese programa.

Nota: shellexecute lo puede ejecutar pero hasta ahí llego.

Saludos 


  • 0

#2 escafandra

escafandra

    Advanced Member

  • Administrador
  • 4.107 mensajes
  • LocationMadrid - España

Escrito 30 noviembre 2018 - 07:08

Lo que pides es complicado pero puedes ejecutar esa aplicación dentro de tu formulario simulando que es parte de tu propia aplicación..

 

 

Saludos.


  • 0

#3 Caral

Caral

    Advanced Member

  • Moderador
  • PipPipPip
  • 4.266 mensajes
  • LocationCosta Rica

Escrito 30 noviembre 2018 - 09:33

Hola

Y como hago eso ?

Me lo pones dificil.

Saludos


  • 0

#4 escafandra

escafandra

    Advanced Member

  • Administrador
  • 4.107 mensajes
  • LocationMadrid - España

Escrito 01 diciembre 2018 - 05:54

Hola
Y como hago eso ?
Me lo pones dificil.
Saludos


No es tan difícil.

Puedes hacerlo con FindWindow si conoces el nombre de la clase de ventana y/o el nombre de la ventana. Eso no me gusta mucho porque deberías evitar que esa app se ejecutara dos veces. Es mejor ejecutar la app escondida, enumnerar las ventanas para encontrar la que corresponda con su PID y asignarle como Parent la ventana donde quieras que se vea. Si a esto le añades que le quitas el Frame y la convertes en estilo WS_BORDER, el efecto está conseguido.

 

Te pongo dos formas de ejecutar, con CreateProcess y con ShellExecuteEx:


delphi
  1. function GetProcessId(hProcess: THANDLE): DWORD; stdcall; external Kernel32;
  2.  
  3.  
  4. function GetWindowFromPId(PId: DWORD): THandle;
  5. type
  6. TWinParam = record
  7. Handle: THandle;
  8. PId: DWORD;
  9. end;
  10. PWinParam = ^TWinParam;
  11. var
  12. WinParam: TWinParam;
  13.  
  14. function EnumWindowsProc(Handle: Thandle; lParam: LPARAM): BOOL; stdcall;
  15. var
  16. PId: DWORD;
  17. begin
  18. Result:= true;
  19. PId:= 0;
  20. GetWindowThreadProcessId(Handle, PId);
  21. if PWinParam(lParam).PId = PId then
  22. begin
  23. PWinParam(lParam).Handle:= Handle;
  24. Result:= false;
  25. end;
  26. end;
  27.  
  28. begin
  29. WinParam.Handle:= 0;
  30. WinParam.PId:= PId;
  31. EnumWindows(@EnumWindowsProc, LPARAM(@WinParam));
  32. repeat
  33. Result:= WinParam.Handle;
  34. WinParam.Handle:= Windows.GetParent(Result);
  35. until WinParam.Handle = 0;
  36. end;
  37.  
  38. function ExecuteAsChild(CommandLine: String; Handle: THandle): THandle;
  39. var
  40. SI: TStartupInfo;
  41. PI: TProcessInformation;
  42. CR: TRect;
  43. begin
  44. ZeroMemory(@SI, sizeof(TStartupInfo));
  45. SI.cb:= sizeof(SI);
  46. SI.dwFlags:= STARTF_USESHOWWINDOW or STARTF_USEPOSITION or STARTF_USESIZE;
  47. Result:= 0;
  48. if CreateProcess(nil, PCHAR(CommandLine), nil, nil, false, 0, nil, nil, SI, PI) then
  49. begin
  50. WaitForInputIdle(PI.hProcess, 10000);
  51. Result:= GetWindowFromPId(PI.dwProcessId);
  52. Windows.SetParent(Result, Handle);
  53. GetClientRect(Handle, CR);
  54. SetWindowLong(Result, GWL_STYLE, WS_BORDER);
  55. SetWindowPos(Result, 0, 0, 0, CR.Right-CR.Left, CR.Bottom-CR.Top, SWP_SHOWWINDOW);
  56. CloseHandle(PI.hProcess);
  57. CloseHandle(PI.hThread);
  58. end;
  59. end;
  60.  
  61. function ExecuteAsChild2(ExeFile: String; Handle: THandle): THandle;
  62. var
  63.   SI: TShellExecuteInfo;
  64.   CR: TRect;
  65. begin
  66.   ZeroMemory(@SI, sizeof(SI));
  67.   SI.cbSize:= SizeOf(SI);
  68.   SI.fMask:=  SEE_MASK_NOCLOSEPROCESS;
  69.   SI.lpVerb:= 'Open';
  70.   SI.lpFile:= PChar(ExeFile);
  71.   SI.nShow:=  SW_HIDE;
  72.  
  73.   Result:= 0;
  74.   if ShellExecuteEx(@SI) then
  75.   begin
  76.     WaitForInputIdle(SI.hProcess, 5000);
  77.     Result:= GetWindowFromPId(GetProcessId(SI.hProcess));
  78.     Windows.SetParent(Result, Handle );
  79.     Windows.GetClientRect(Handle, CR);
  80.     SetWindowLong(Result, GWL_STYLE, WS_BORDER);
  81.     SetWindowPos(Result, 0, 0, 0, CR.Right-CR.Left, CR.Bottom-CR.Top, SWP_SHOWWINDOW);
  82.     CloseHandle(SI.hProcess);
  83.   end;
  84. end;

Y la forma de usarlo es la misma para las dos versiones:


delphi
  1. ExecuteAsChild('Notepad.exe', Panel1.Handle);

PD: Solo tengo delphi6 a mano en este momento, eso me ha obligado a importar la API GetProcessId pero en una versión más moderna no hará falta.

 

 

Saludos.


  • 0

#5 Caral

Caral

    Advanced Member

  • Moderador
  • PipPipPip
  • 4.266 mensajes
  • LocationCosta Rica

Escrito 01 diciembre 2018 - 09:42

Hola

Muchas gracias, siempre lo he dicho: sois unos genios.

Lo pruebo y te digo.

Saludos


  • 0

#6 Caral

Caral

    Advanced Member

  • Moderador
  • PipPipPip
  • 4.266 mensajes
  • LocationCosta Rica

Escrito 01 diciembre 2018 - 10:20

Hola

Hice un programa nuevo VCL con un form un panel y un boton.

No me funcionaba y me puse a hacer cosas.

1 puse en USES ShellAPI

2 me daba error en Windows y lo cambie por Winapi.Windows

Ahi el programa corrio pero

 

me sale este error y no se que es

 

Access violation at address 76ce294e in module
KERNELBASE.dll write of address 005d04be
 
Saludos

  • 0

#7 escafandra

escafandra

    Advanced Member

  • Administrador
  • 4.107 mensajes
  • LocationMadrid - España

Escrito 02 diciembre 2018 - 04:56

 

Hola

Hice un programa nuevo VCL con un form un panel y un boton.

No me funcionaba y me puse a hacer cosas.

1 puse en USES ShellAPI

2 me daba error en Windows y lo cambie por Winapi.Windows

Ahi el programa corrio pero

 

me sale este error y no se que es

 

Access violation at address 76ce294e in module
KERNELBASE.dll write of address 005d04be
 
Saludos

 

 

Hasta esta tarde no podré usar Berlin pero lo he pro bado con D6, D7 y Lazarus.

 

En Lazarus no funciona con funciones dentro de funciones pero si de la forma tradicional.

Te subo la versión Lazarus en un ejemplo completo estilo $MODE Delphi para compativilidad con delphi:


delphi
  1. unit Unit1;
  2.  
  3. //{$mode objfpc}{$H+}
  4. {$MODE Delphi}
  5. interface
  6.  
  7. uses
  8.   Windows, ShellApi, Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ExtCtrls,
  9.   StdCtrls;
  10.  
  11. type
  12.  
  13.   { TForm1 }
  14.  
  15.   TForm1 = class(TForm)
  16.     Button1: TButton;
  17.     Button2: TButton;
  18.     Panel1: TPanel;
  19.     procedure Button1Click(Sender: TObject);
  20.     procedure Button2Click(Sender: TObject);
  21.   private
  22.     ChildHandle: THandle;
  23.   public
  24.  
  25.   end;
  26.  
  27. function GetProcessId(hProcess: THANDLE): DWORD; stdcall;  external  Kernel32;
  28.  
  29. var
  30.   Form1: TForm1;
  31.  
  32. implementation
  33.  
  34. {$R *.lfm}
  35.  
  36. { TForm1 }
  37. type
  38.   TWinParam = record
  39.     Handle: THandle;
  40.     PId: DWORD;
  41.   end;
  42.   PWinParam = ^TWinParam;
  43.  
  44. function EnumWindowsProc(Handle: Thandle; Value: LPARAM): LongBool; stdcall;
  45. var
  46.   PId: DWORD;
  47. begin
  48.   Result:= true;
  49.   PId:= 0;
  50.   Windows.GetWindowThreadProcessId(Handle, PId);
  51.   if (PWinParam(Value).PId = PId) then
  52.   begin
  53.     PWinParam(Value).Handle:= Handle;
  54.     Result:= false;
  55.   end;
  56. end;
  57.  
  58. function GetWindowFromPId(PId: DWORD): THandle;
  59. var
  60.   WinParam: TWinParam;
  61. begin
  62.   WinParam.Handle:= 0;
  63.   WinParam.PId:= PId;
  64.   EnumWindows(@EnumWindowsProc, LPARAM(@WinParam));
  65.   repeat
  66.     Result:= WinParam.Handle;
  67.     WinParam.Handle:= Windows.GetParent(Result);
  68.   until WinParam.Handle = 0;
  69. end;
  70.  
  71. function ExecuteAsChild(CommandLine: String; Handle: THandle): THandle;
  72. var
  73.   SI: TStartupInfo;
  74.   PI: TProcessInformation;
  75.   CR: TRect;
  76. begin
  77.   ZeroMemory(@SI, sizeof(TStartupInfo));
  78.   SI.cb:= sizeof(SI);
  79.   SI.dwFlags:= STARTF_USESHOWWINDOW or STARTF_USEPOSITION or STARTF_USESIZE;
  80.   Result:= 0;
  81.   if CreateProcess(nil, PCHAR(CommandLine), nil, nil, false, 0, nil, nil, SI, PI) then
  82.   begin
  83.     WaitForInputIdle(PI.hProcess, 10000);
  84.     Result:= GetWindowFromPId(PI.dwProcessId);
  85.     Windows.SetParent(Result, Handle);
  86.     GetClientRect(Handle, CR);
  87.     SetWindowLong(Result, GWL_STYLE, WS_BORDER);
  88.     SetWindowPos(Result, 0, 0, 0, CR.Right-CR.Left, CR.Bottom-CR.Top, SWP_SHOWWINDOW);
  89.     CloseHandle(PI.hProcess);
  90.     CloseHandle(PI.hThread);
  91.   end;
  92. end;
  93.  
  94. function ExecuteAsChild2(ExeFile: AnsiString; Handle: THandle): THandle;
  95. var
  96.   SI: TShellExecuteInfoA;
  97.   CR: TRect;
  98. begin
  99.   ZeroMemory(@SI, sizeof(SI));
  100.   SI.cbSize:= SizeOf(SI);
  101.   SI.fMask:=  SEE_MASK_NOCLOSEPROCESS;
  102.   SI.lpVerb:= 'Open';
  103.   SI.lpFile:= PAnsiCHAR(ExeFile);
  104.   Result:= 0;
  105.   if ShellExecuteExA(@SI) then
  106.   begin
  107.     WaitForInputIdle(SI.hProcess, 50000);
  108.     Result:= GetWindowFromPId(GetProcessId(SI.hProcess));
  109.     Windows.SetParent(Result, Handle );
  110.     Windows.GetClientRect(Handle, CR);
  111.     SetWindowLong(Result, GWL_STYLE, WS_BORDER);
  112.     SetWindowPos(Result, 0, 0, 0, CR.Right-CR.Left, CR.Bottom-CR.Top, SWP_SHOWWINDOW);
  113.     CloseHandle(SI.hProcess);
  114.   end;
  115. end;
  116.  
  117. procedure TForm1.Button1Click(Sender: TObject);
  118. begin
  119.   ChildHandle:= ExecuteAsChild('Notepad.exe', Panel1.Handle);
  120. end;
  121.  
  122. procedure TForm1.Button2Click(Sender: TObject);
  123. begin
  124.   PostMessage(ChildHandle, WM_QUIT, 0, 0);
  125. end;
  126.  
  127. end.

Adjunto proyecto para delphi6 y 7 y proyecto Lazarus 1.6.4

 

Si tengo tiempo esta tarde pruebo en Berlin

 

 

Saludos.

Archivos adjuntos


  • 0

#8 escafandra

escafandra

    Advanced Member

  • Administrador
  • 4.107 mensajes
  • LocationMadrid - España

Escrito 02 diciembre 2018 - 08:54   Mejor respuesta

Acabo de llegar a casa y he adaptado el código para Berlin. El problema es el UNICODE de la función ExecuteAsChild, sin embargo ExecuteAsChild2 no requiere cambios. Recordar que ambas funciones realizan exactamente lo mismo y están puestas para que cada uno elija la forma que le guste más.
 
Este sería el código completo en un proyecto partiendo de cero en Berlin:


delphi
  1. unit Unit1;
  2.  
  3. interface
  4.  
  5. uses
  6.   Winapi.Windows, Winapi.Messages, Winapi.ShellApi, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  7.   Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Vcl.ExtCtrls;
  8.  
  9. type
  10.   TForm2 = class(TForm)
  11.     Button2: TButton;
  12.     Button1: TButton;
  13.     Panel1: TPanel;
  14.     procedure Button1Click(Sender: TObject);
  15.     procedure Button2Click(Sender: TObject);
  16.   private
  17.     ChildHandle: THandle;
  18.   public
  19.     { Public declarations }
  20.   end;
  21.  
  22. var
  23.   Form2: TForm2;
  24.  
  25. implementation
  26.  
  27. {$R *.dfm}
  28.  
  29. function GetWindowFromPId(PId: DWORD): THandle;
  30. type
  31.   TWinParam = record
  32.     Handle: THandle;
  33.     PId: DWORD;
  34.   end;
  35.   PWinParam = ^TWinParam;
  36. var
  37.   WinParam: TWinParam;
  38.  
  39.   function EnumWindowsProc(Handle: Thandle; lParam: LPARAM): BOOL; stdcall;
  40.   var
  41.     PId: DWORD;
  42.   begin
  43.     Result:= true;
  44.     PId:= 0;
  45.     GetWindowThreadProcessId(Handle, PId);
  46.     if PWinParam(lParam).PId = PId then
  47.     begin
  48.       PWinParam(lParam).Handle:= Handle;
  49.       Result:= false;
  50.     end;
  51.   end;
  52.  
  53. begin
  54.   WinParam.Handle:= 0;
  55.   WinParam.PId:= PId;
  56.   EnumWindows(@EnumWindowsProc, LPARAM(@WinParam));
  57.   repeat
  58.     Result:= WinParam.Handle;
  59.     WinParam.Handle:= Winapi.Windows.GetParent(Result);
  60.   until WinParam.Handle = 0;
  61. end;
  62.  
  63. function ExecuteAsChild(CommandLine: AnsiString; Handle: THandle): THandle;
  64. var
  65.   SI: TStartupInfoA;
  66.   PI: TProcessInformation;
  67.   CR: TRect;
  68. begin
  69.   ZeroMemory(@SI, sizeof(SI));
  70.   SI.cb:= sizeof(sizeof(SI));
  71.   SI.dwFlags:=  STARTF_USESHOWWINDOW or STARTF_USEPOSITION or STARTF_USESIZE;
  72.   Result:= 0;
  73.   if CreateProcessA(nil, PAnsiCHAR(CommandLine), nil, nil, false, 0, nil, nil, SI, PI) then
  74.   begin
  75.     WaitForInputIdle(PI.hProcess, 10000);
  76.     Result:= GetWindowFromPId(PI.dwProcessId);
  77.     Winapi.Windows.SetParent(Result, Handle);
  78.     GetClientRect(Handle, CR);
  79.     SetWindowLong(Result, GWL_STYLE, WS_BORDER);
  80.     SetWindowPos(Result, 0, 0, 0, CR.Right-CR.Left, CR.Bottom-CR.Top, SWP_SHOWWINDOW);
  81.     CloseHandle(PI.hProcess);
  82.     CloseHandle(PI.hThread);
  83.   end;
  84. end;
  85.  
  86. function ExecuteAsChild2(ExeFile: String; Handle: THandle): THandle;
  87. var
  88.   SI: TShellExecuteInfo;
  89.   CR: TRect;
  90. begin
  91.   ZeroMemory(@SI, sizeof(SI));
  92.  
  93.   SI.cbSize:= SizeOf(SI);
  94.   SI.fMask:=  SEE_MASK_NOCLOSEPROCESS;
  95.   SI.lpVerb:= 'Open';
  96.   SI.lpFile:= PChar(ExeFile);
  97.   SI.nShow:=  SW_HIDE;
  98.  
  99.   Result:= 0;
  100.   if ShellExecuteEx(@SI) then
  101.   begin
  102.     WaitForInputIdle(SI.hProcess, 5000);
  103.     Result:= GetWindowFromPId(GetProcessId(SI.hProcess));
  104.     Winapi.Windows.SetParent(Result, Handle );
  105.     Winapi.Windows.GetClientRect(Handle, CR);
  106.     SetWindowLong(Result, GWL_STYLE, WS_BORDER);
  107.     SetWindowPos(Result, 0, 0, 0, CR.Right-CR.Left, CR.Bottom-CR.Top, SWP_SHOWWINDOW);
  108.     CloseHandle(SI.hProcess);
  109.   end;
  110. end;
  111.  
  112.  
  113. procedure TForm2.Button1Click(Sender: TObject);
  114. begin
  115.   ChildHandle:= ExecuteAsChild('Notepad.exe', Panel1.Handle);
  116. end;
  117.  
  118. procedure TForm2.Button2Click(Sender: TObject);
  119. begin
  120.   Winapi.Windows.PostMessage(ChildHandle, WM_QUIT, 0, 0);
  121. end;
  122.  
  123. end.

En la imagen se ejecuta el notepad.exe dentro de un TPanel:
 
c6af221f93d1c37b920a05819d67bb49o.gif
 
Subo el proyecto.
 
Saludos,

Archivos adjuntos


  • 0

#9 Caral

Caral

    Advanced Member

  • Moderador
  • PipPipPip
  • 4.266 mensajes
  • LocationCosta Rica

Escrito 02 diciembre 2018 - 01:58

Hola

Muchas gracias

Ya lo pruebo.

Saludos

Edito:

Funciona a la perfección, muchas gracias amigo.

Saludos


  • 0

#10 pcicom

pcicom

    Advanced Member

  • Miembro Platino
  • PipPipPip
  • 267 mensajes
  • LocationMéxico

Escrito 05 diciembre 2018 - 05:57

Excelente,   y como se podria agregar que se pudea redimensionar junto con la forma ?


  • 0

#11 escafandra

escafandra

    Advanced Member

  • Administrador
  • 4.107 mensajes
  • LocationMadrid - España

Escrito 06 diciembre 2018 - 02:35

Excelente,   y como se podria agregar que se pudea redimensionar junto con la forma ?

 

La forma mas fácil es en el evento OnResize del formulario o del Panel del ejemplo. También es recomendable asegurar que se cierra la aplicación que hemos ejecutado en nuestra ventana, al cerrar nuestro programa.

 

Un ejemplo:


delphi
  1. procedure TForm2.FormClose(Sender: TObject; var Action: TCloseAction);
  2. begin
  3. PostMessage(ChildHandle, WM_QUIT, 0, 0);
  4. end;
  5.  
  6. procedure TForm2.Panel1Resize(Sender: TObject);
  7. begin
  8. SetWindowPos(ChildHandle, 0, 0, 0, Panel1.Width, Panel1.Height, SWP_NOMOVE or SWP_NOZORDER or SWP_NOACTIVATE);
  9. end;

Subo los proyectos con estas nuevas opciones.

 

 

Saludos.

Archivos adjuntos


  • 0

#12 pcicom

pcicom

    Advanced Member

  • Miembro Platino
  • PipPipPip
  • 267 mensajes
  • LocationMéxico

Escrito 07 diciembre 2018 - 11:22

Genio..  de la lampara Delphi !!!!  jejeje     Saludos...


  • 0

#13 dooper

dooper

    Advanced Member

  • Miembros
  • PipPipPip
  • 298 mensajes

Escrito 13 diciembre 2021 - 02:00

Que gran aporte. Es lo que venía buscando, pero no funciona si quieres insertar en el Panel1 un acrobat.exe (no hace nada) o simplemente la  calculadora (esta última, lo hace fuera).

Como se podría ejecutar para ver un pdf dentro del panel o un .doc?

Un saludo


  • 0

#14 egostar

egostar

    missing my father, I love my mother.

  • Administrador
  • 14.446 mensajes
  • LocationMéxico

Escrito 13 diciembre 2021 - 11:13

Que gran aporte. Es lo que venía buscando, pero no funciona si quieres insertar en el Panel1 un acrobat.exe (no hace nada) o simplemente la  calculadora (esta última, lo hace fuera).
Como se podría ejecutar para ver un pdf dentro del panel o un .doc?
Un saludo

 
Necesitas un componente OLEContainer y abrir el PDF
 


delphi
  1. procedure TForm1.Button5Click(Sender: TObject);
  2. begin
  3.   OleContainer1.CreateObjectFromFile('D:\Documentos\CFDIv40.pdf', False);
  4. end;

Saludos

Archivos adjuntos


  • 0

#15 dooper

dooper

    Advanced Member

  • Miembros
  • PipPipPip
  • 298 mensajes

Escrito 14 diciembre 2021 - 09:14

 
Necesitas un componente OLEContainer y abrir el PDF
 


delphi
  1. procedure TForm1.Button5Click(Sender: TObject);
  2. begin
  3.   OleContainer1.CreateObjectFromFile('D:\Documentos\CFDIv40.pdf', False);
  4. end;

Saludos

Gracias Egostar, mi problema está en que uso CodeTyphon 5.6 y ese componente no lo tiene.

Estoy loco por conseguir visualizar un pdf dentro de un panel o incluso mejor con tabsheet de un pagecontrol, pero no veo nada.

 

Pensaba que este pequeño código sería mi salvación, pero veo que no! seguiré en el intento.

 

Me alegro saber de ti, un cordial saludo compañero,


  • 0

#16 egostar

egostar

    missing my father, I love my mother.

  • Administrador
  • 14.446 mensajes
  • LocationMéxico

Escrito 14 diciembre 2021 - 01:37

Gracias Egostar, mi problema está en que uso CodeTyphon 5.6 y ese componente no lo tiene.

Estoy loco por conseguir visualizar un pdf dentro de un panel o incluso mejor con tabsheet de un pagecontrol, pero no veo nada.

 

Pensaba que este pequeño código sería mi salvación, pero veo que no! seguiré en el intento.

 

Me alegro saber de ti, un cordial saludo compañero,

 

Ah vaya, pues ahí si desconozco, no manejo CodeTyphon.  

 

Un gusto saludarte y verte por acá (y) espero que todo vaya bien y que la pandemia haya sido leve por allá.

 

Saludos


  • 0

#17 dooper

dooper

    Advanced Member

  • Miembros
  • PipPipPip
  • 298 mensajes

Escrito 16 diciembre 2021 - 11:42

Ah vaya, pues ahí si desconozco, no manejo CodeTyphon.  

 

Un gusto saludarte y verte por acá (y) espero que todo vaya bien y que la pandemia haya sido leve por allá.

 

Saludos

Gracias Egostar. Hay un ejemplo con codigo Lazarus que si me vale para CodeTyphon, pero tampoco funciona.


  • 1




IP.Board spam blocked by CleanTalk.