问题描述
我想将mozilla firefox嵌入到我的应用程序中,而不使用任何activex控件(TWebBrowser wrapper,mozilla ActiveX ...)。我尝试使用TWebBrowser(实际上是bsalsa的嵌入式webBrowser,这是更好),但所有版本的IE似乎与流行的JavaScript框架和库(JQuery,ExtJS ...)的一些功能不兼容。
$我的问题是:我可以从我的应用程序中调用firefox的Exe(是否可以使用DDE或OLE),最重要的是使用TFrame或类似的东西在我的应用程序中显示?
等待你的建议
问候,M
你需要清理该代码有一些工作,你会如何谈论到Firefox。但是这里是如何将任何应用程序嵌入到Delphi表单中。
DFM文件
对象frmMain:TfrmMain
左= 195
顶部= 154
宽度= 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
对象pnlTop:TPanel
Left = 0
顶部= 0
宽度= 519
高度= 292
Align = alTop
锚点= [akLeft,akTop,akRight,akBottom]
BevelInner = bvLowered
TabOrder = 0
end
对象btnLoadApp:TButton
左= 172
顶部= 297
宽度= 75
高度= 25
锚点= [akLeft,akBottom]
Caption ='加载'
TabOrder = 1
OnClick = btnLoadAppClick
end
对象btnKill:TButton
左= 260
顶部= 297
宽度= 75
高度= 25
锚点= [akLeft ,akBottom]
Caption ='Kill'
TabOrder = 2
OnClick = btnKillClick
end
end
main.pas文件
unit main;
interface
使用
Windows,消息,SysUtils,变体,类,图形,控件,窗体,
对话框,StdCtrls,ExtCtrls,ShellApi;
type
TfrmMain = class(TForm)
pnlTop:TPanel;
btnLoadApp:TButton;
btnKill:TButton;
procedure btnLoadAppClick(Sender:TObject);
程序btnKillClick(发件人:TObject);
private
{私有声明}
AppWnd:DWORD;
public
{公开声明}
end;
var
frmMain:TfrmMain;
执行
{$ R * .dfm}
程序TfrmMain.btnLoadAppClick(发件人:TObject);
var
ExecuteFile:string;
SEInfo:TShellExecuteInfo;
begin
ExecuteFile:='c:\Windows\\\
otepad.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;
结束
如果ShellExecuteEx(@SEInfo)然后
begin
AppWnd:= FindWindow(nil,PChar('Untitled - Notepad'));
如果AppWnd<> 0然后
begin
Windows.SetParent(AppWnd,SEInfo.Wnd);
ShowWindow(AppWnd,SW_SHOWMAXIMIZED);
ShowWindow(AppWnd,SW_SHOWMAXIMIZED);
结束
end
else
ShowMessage('Error notepad!');
结束
程序TfrmMain.btnKillClick(发件人:TObject);
begin
if(AppWnd<> 0)then
begin
PostMessage(AppWnd,WM_Close,0,0);
AppWnd:= 0;
结束
结束
结束。
I would like to embed mozilla firefox into my application WITHOUT using any activex control (TWebBrowser wrapper, mozilla ActiveX...). I tried using TWebBrowser (actually bsalsa's embedded webBrowser wich is by far better), but all versions of IE seem incompatible with some features of popular javascript framework and libs (JQuery, ExtJS...).
My question is : can I call firefox's Exe from my application (is it possible with DDE or OLE) and above all SHOW IT inside my app using a TFrame or anything similar ?
waiting for your suggestionsRegards, M
You'll need to clean up the code a bit and work out how you'll "talk" to Firefox.
But here is how you can embed any app inside a Delphi form.
DFM File
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
main.pas file 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.
这篇关于将应用程序(exe文件)嵌入另一个exe文件(mozEmbed like)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!