将应用程序(exe文件)嵌入到另一个exe文件中(mozEmbed like)

M0-*_*-3E 5 embed delphi firefox dde

我想将mozilla firefox嵌入到我的应用程序中而不使用任何activex控件(TWebBrowser包装器,mozilla ActiveX ...).我尝试使用TWebBrowser(实际上bsalsa的嵌入式webBrowser更好),但所有版本的IE似乎都与流行的javascript框架和libs(JQuery,ExtJS ......)的某些功能不兼容.

我的问题是:我可以从我的应用程序调用firefox的Exe(可能使用DDE或OLE),最重要的是在我的应用程序中使用TFrame或类似的东西显示它吗?

等待你的建议问候,M

Cat*_*arz 5

您需要稍微清理代码并找出与Firefox"交谈"的方式.
但是这里是你如何在Delphi表单中嵌入任何应用程序.

DFM文件

object frmMain: TfrmMain
  Left = 195
  Top = 154
  Width = 527
  Height = 363
  Caption = 'Containership Test'
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'MS Sans Serif'
  Font.Style = []
  OldCreateOrder = False
  DesignSize = (
    519
    329)
  PixelsPerInch = 96
  TextHeight = 13
  object pnlTop: TPanel
    Left = 0
    Top = 0
    Width = 519
    Height = 292
    Align = alTop
    Anchors = [akLeft, akTop, akRight, akBottom]
    BevelInner = bvLowered
    TabOrder = 0
  end
  object btnLoadApp: TButton
    Left = 172
    Top = 297
    Width = 75
    Height = 25
    Anchors = [akLeft, akBottom]
    Caption = 'Load'
    TabOrder = 1
    OnClick = btnLoadAppClick
  end
  object btnKill: TButton
    Left = 260
    Top = 297
    Width = 75
    Height = 25
    Anchors = [akLeft, akBottom]
    Caption = 'Kill'
    TabOrder = 2
    OnClick = btnKillClick
  end
end
Run Code Online (Sandbox Code Playgroud)

main.pas文件

unit main;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ExtCtrls, ShellApi;

type
  TfrmMain = class(TForm)
    pnlTop: TPanel;
    btnLoadApp: TButton;
    btnKill: TButton;
    procedure btnLoadAppClick(Sender: TObject);
    procedure btnKillClick(Sender: TObject);
  private
    { Private declarations }
    AppWnd : DWORD;
  public
    { Public declarations }
  end;

var
  frmMain: TfrmMain;

implementation

{$R *.dfm}

procedure TfrmMain.btnLoadAppClick(Sender: TObject);
var
  ExecuteFile : string;
  SEInfo: TShellExecuteInfo;
begin
  ExecuteFile:='c:\Windows\notepad.exe';

  FillChar(SEInfo, SizeOf(SEInfo), 0) ;
  SEInfo.cbSize := SizeOf(TShellExecuteInfo) ;
  with SEInfo do
  begin
    fMask := SEE_MASK_NOCLOSEPROCESS;
    Wnd := pnlTop.Handle;
    lpFile := PChar(ExecuteFile) ;
    nShow := SW_HIDE;
  end;
  if ShellExecuteEx(@SEInfo) then
  begin
    AppWnd := FindWindow(nil, PChar('Untitled - Notepad'));
    if AppWnd <> 0 then
    begin
      Windows.SetParent(AppWnd, SEInfo.Wnd);
      ShowWindow(AppWnd, SW_SHOWMAXIMIZED);
      ShowWindow(AppWnd, SW_SHOWMAXIMIZED);
    end;
  end
  else
    ShowMessage('Error starting notepad!') ;
end;

procedure TfrmMain.btnKillClick(Sender: TObject);
begin
  if (AppWnd <> 0) then
  begin
    PostMessage(AppWnd, WM_Close, 0, 0);
    AppWnd := 0;
  end;
end;

end.
Run Code Online (Sandbox Code Playgroud)