Club Delphi  
    Paypal   FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Principal > API de Windows
Registrarse FAQ Miembros Calendario Guía de estilo Temas de Hoy

 
 
Herramientas Buscar en Tema Desplegado
  #6  
Antiguo 25-05-2016
gaunmanuel gaunmanuel is offline
Miembro
 
Registrado: may 2015
Posts: 48
Poder: 0
gaunmanuel Va por buen camino
Gracias a todos.
Ya habia revisado todos los links y opciones que me dan.
Pero ya descubri el porque, siempre habia hecho el ejemplo con la calculadora de windows, y por alguna razon esta aplicacion no se puede embeber en la forma.
Sin embargo con otra aplicacion hecha en Delphi funciona correctamente, aqui les dejo el codigo como lo use:

Código Delphi [-]
unit ufrmMain;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, Menus, shellApi;

type
  TForm1 = class(TForm)
    MainMenu1: TMainMenu;
    mnuNotepad: TMenuItem;
    procedure mnuNotepadClick(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
  private
    { Private declarations }
      H: THandle;
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

type
  TWindowRec = record
    Handle: THandle;
    ProcessId: Cardinal;
    WindowName: PChar;
  end;
  PWindowRec = ^TWindowRec;

function EnumWindowsProc(Handle: Thandle; lParam: LPARAM): BOOL; stdcall;
var
  ProcessId: Cardinal;
  Buffer: PChar;
  Size: Integer;
begin
  Result:= TRUE;
  ProcessId:= 0;
  GetWindowThreadProcessId(Handle, ProcessId);
  if ProcessId = PWindowRec(lParam).ProcessId then
  begin
    if PWindowRec(lParam).WindowName <> nil then
    begin
      Size:= GetWindowTextLength(Handle) + 1;
      GetMem(Buffer,Size);
      try
        GetWindowText(Handle,Buffer,Size);
        if StrIcomp(PWindowRec(lParam).WindowName, Buffer) = 0 then
        begin
          PWindowRec(lParam).Handle:= Handle;
          Result:= FALSE;
        end;
      finally
        Freemem(Buffer);
      end;
    end else
    begin
      PWindowRec(lParam).Handle:= Handle;
      Result:= FALSE;
    end;
  end;
end;

function GetWindowFromProcessId(ProcessId: Cardinal; WindowName: PChar): THandle;
var
  WindowRec: TWindowRec;
begin
  FillChar(WindowRec,Sizeof(WindowRec),0);
  WindowRec.ProcessId:= ProcessId;
  WindowRec.WindowName:= WindowName;
  EnumWindows(@EnumWindowsProc, LPARAM(@WindowRec));
  Result:= WindowRec.Handle;
end;

function Ejecutar(Cmd: string; WindowName: PChar; Timeout: Cardinal): THandle;
var
  StartupInfo: TStartupInfo;
  ProcessInfo: TProcessInformation;
  Ticks: Cardinal;
begin
  Result:= 0;
  FillChar(StartupInfo,Sizeof(StartupInfo),0);
  StartupInfo.wShowWindow:= SW_SHOW;
  Ticks:= GetTickCount;
  if CreateProcess(nil,PChar(Cmd),nil,nil, FALSE, CREATE_NEW_CONSOLE or
    NORMAL_PRIORITY_CLASS,nil,nil,StartupInfo, ProcessInfo) then
    while (Result = 0) and (GetTickCount - Ticks < TimeOut) do
    begin
      Result:= GetWindowFromProcessId(ProcessInfo.dwProcessId, WindowName);
      if Result = 0 then Sleep(200);
    end;
end;

procedure TForm1.mnuNotepadClick(Sender: TObject);

begin
  H:= Ejecutar('C:\Program Files (x86)\Borland\Delphi7\Projects\LetrasNumerosConsecutivos\Project1.exe',nil,5000);
  Windows.SetParent(H,Handle);
end;

procedure TForm1.FormDestroy(Sender: TObject);
begin
PostMessage(h, WM_CLOSE, 0, 0);

end;

end.

saludos.
Responder Con Cita
 



Normas de Publicación
no Puedes crear nuevos temas
no Puedes responder a temas
no Puedes adjuntar archivos
no Puedes editar tus mensajes

El código vB está habilitado
Las caritas están habilitado
Código [IMG] está habilitado
Código HTML está deshabilitado
Saltar a Foro

Temas Similares
Tema Autor Foro Respuestas Último mensaje
Enviar cordenadas del mouse dentro del form a otro form look OOP 7 30-12-2013 16:58:22
Desplegar un PDF dentro de un Form MAXIUM Varios 2 21-06-2013 20:50:13
al minimizar un Form se quede dentro del Form principal lmpadron C++ Builder 1 11-03-2013 16:42:29
Form contenedor dentro de otro form. vpepen Varios 7 14-04-2011 00:12:30
Un form dentro de otro Ubed Gráficos 7 01-11-2007 20:07:06


La franja horaria es GMT +2. Ahora son las 08:38:32.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi
Copyright 1996-2007 Club Delphi