欢迎页面浏览器如何从OTA包向导中导航到一些URI? [英] How do I get Welcome Page browser navigate to some URI from within OTA package wizard?
问题描述
我想要做的是创建一个查看(不编辑)包含在项目中的HTML页面的功能。欢迎页面已经嵌入了网络浏览器,所以似乎是一个很好的候选人。
Curios为什么?这是一个具有背景的问题信息。
如果您愿意使用这样的黑客:
键入
TOpenNewURLModule = procedure(const URL:string; EditorForm:TCustomForm);
程序OpenURL(const URL:string);
var
EditWindow:INTAEditWindow;
Lib:HMODULE;
OpenNewURLModule:TOpenNewURLModule;
begin
EditWindow:=(BorlandIDEServices as INTAEditorServices).TopEditWindow;
如果没有分配(EditWindow)或未分配(EditWindow.Form)然后
退出;
Lib:= GetModuleHandle('startpageide150.bpl');
如果Lib = 0然后
退出;
OpenNewURLModule:= GetProcAddress(Lib,'@ Urlmodule @ OpenNewURLModule $ qqrx20System @ UnicodeStringp22Editorform @ TEditWindow');
if @OpenNewURLModule<> nil then
OpenNewURLModule(URL,EditWindow.Form);
结束
缺点:
- 这是一个黑客(startpageidexx.bpl不是通过API公开或记录下来的)
- 它是针对Delphi XE的硬编码(您需要其他版本的不同文件名,方法签名可能不一样 - 例如在较旧的AnsiString版本中)
- 如果没有编辑窗口(必须至少有一个开放模块),则不执行任何操作。
- 它始终打开一个新的浏览器视图
编辑:似乎可以重复使用现有的开放式欢迎页面,并使此hack与旧版本的Delphi兼容。以下显示了两种选择:Delphi XE和Delphi 2007(两者似乎都在工作):
键入
IURLModule =界面(IOTAModuleData)
['{9D215B02-6073-45DC-B007-1A2DBCE2D693}']
函数GetURL:string;
程序SetURL(const URL:string);
属性URL:string读取GetURL写入SetURL;
结束
TOpenNewURLModule = procedure(const URL:string; EditorForm:TCustomForm);
函数FindURLModule:IURLModule;
var
I:整数;
begin
结果:= nil;
与BorlandIDEServices作为IOTAModuleServices做
为I:= 0到ModuleCount - 1 do
如果支持(Modules [I],IURLModule,Result)then
Break;
结束
程序OpenURL(const URL:string; ReuseExistingView:Boolean = True);
{$ IFDEF VER220} // Delphi XE
const
SStartPageIDE ='startpageide150.bpl';
SOpenNewURLModule ='@ Urlmodule @ OpenNewURLModule $ qqrx20System @ UnicodeStringp22Editorform @ TEditWindow';
{$ ENDIF}
{$ IFDEF VER185} // Delphi 2007
const
SStartPageIDE ='startpageide100.bpl';
SOpenNewURLModule ='@ Urlmodule @ OpenNewURLModule $ qqrx17System @ AnsiStringp22Editorform @ TEditWindow';
{$ ENDIF}
var
模块:IURLModule;
EditWindow:INTAEditWindow;
Lib:HMODULE;
OpenNewURLModule:TOpenNewURLModule;
begin
EditWindow:= nil;
模块:= nil;
如果ReuseExistingView然后
模块:= FindURLModule;
如果分配(模块)然后
开始
Module.URL:= URL;
(模块为IOTAModule)。
end
else
begin
{$ IFDEF VER220}
EditWindow:=(BorlandIDEServices as INTAEditorServices).TopEditWindow;
{$ ENDIF}
{$ IFDEF VER185}
如果分配((BorlandIDEServices作为IOTAEditorServices).TopView)然后
EditWindow:=(BorlandIDEServices作为IOTAEditorServices).TopView.GetEditWindow;
{$ ENDIF}
如果没有分配(EditWindow)或未分配(EditWindow.Form)然后
退出;
Lib:= GetModuleHandle(SStartPageIDE);
如果Lib = 0然后
退出;
OpenNewURLModule:= GetProcAddress(Lib,SOpenNewURLModule);
if @OpenNewURLModule<> nil then
OpenNewURLModule(URL,EditWindow.Form);
结束
结束
剩余的缺点:
- 它仍然是一个黑客
- 它仍然是硬编码,对于Delphi XE(Unicode)和Delphi 2007(ANSI)
- 它仍然如果没有编辑窗口,则不执行任何操作
如果您需要其他版本的兼容性,也可以将其作为开始。 >
What I'm trying to do is to create an ability to view (not to edit) the HTML pages included into project. The Welcome Page already has embedded web browser, so it appears to be a good candidate for that.
Curios why? Here is a question with background info.
In case you're willing to use a hack like this:
type
TOpenNewURLModule = procedure(const URL: string; EditorForm: TCustomForm);
procedure OpenURL(const URL: string);
var
EditWindow: INTAEditWindow;
Lib: HMODULE;
OpenNewURLModule: TOpenNewURLModule;
begin
EditWindow := (BorlandIDEServices as INTAEditorServices).TopEditWindow;
if not Assigned(EditWindow) or not Assigned(EditWindow.Form) then
Exit;
Lib := GetModuleHandle('startpageide150.bpl');
if Lib = 0 then
Exit;
OpenNewURLModule := GetProcAddress(Lib, '@Urlmodule@OpenNewURLModule$qqrx20System@UnicodeStringp22Editorform@TEditWindow');
if @OpenNewURLModule <> nil then
OpenNewURLModule(URL, EditWindow.Form);
end;
Cons:
- it's a hack (startpageidexx.bpl is not exposed through the API or documented)
- it's hard-coded for Delphi XE (you need a different file name for other versions, the method signature might be different, too - e.g. in older AnsiString versions)
- it does nothing if there is no edit window (there has to be at least one open module)
- it always opens a new browser view
EDIT: It seems to be possible to reuse an existing open Welcome page, as well as make this hack compatible with older versions of Delphi. The following shows two alternatives, Delphi XE and Delphi 2007 (both seem to be working):
type
IURLModule = interface(IOTAModuleData)
['{9D215B02-6073-45DC-B007-1A2DBCE2D693}']
function GetURL: string;
procedure SetURL(const URL: string);
property URL: string read GetURL write SetURL;
end;
TOpenNewURLModule = procedure(const URL: string; EditorForm: TCustomForm);
function FindURLModule: IURLModule;
var
I: Integer;
begin
Result := nil;
with BorlandIDEServices as IOTAModuleServices do
for I := 0 to ModuleCount - 1 do
if Supports(Modules[I], IURLModule, Result) then
Break;
end;
procedure OpenURL(const URL: string; ReuseExistingView: Boolean = True);
{$IFDEF VER220} // Delphi XE
const
SStartPageIDE = 'startpageide150.bpl';
SOpenNewURLModule = '@Urlmodule@OpenNewURLModule$qqrx20System@UnicodeStringp22Editorform@TEditWindow';
{$ENDIF}
{$IFDEF VER185} // Delphi 2007
const
SStartPageIDE = 'startpageide100.bpl';
SOpenNewURLModule = '@Urlmodule@OpenNewURLModule$qqrx17System@AnsiStringp22Editorform@TEditWindow';
{$ENDIF}
var
Module: IURLModule;
EditWindow: INTAEditWindow;
Lib: HMODULE;
OpenNewURLModule: TOpenNewURLModule;
begin
EditWindow := nil;
Module := nil;
if ReuseExistingView then
Module := FindURLModule;
if Assigned(Module) then
begin
Module.URL := URL;
(Module as IOTAModule).Show;
end
else
begin
{$IFDEF VER220}
EditWindow := (BorlandIDEServices as INTAEditorServices).TopEditWindow;
{$ENDIF}
{$IFDEF VER185}
if Assigned((BorlandIDEServices as IOTAEditorServices).TopView) then
EditWindow := (BorlandIDEServices as IOTAEditorServices).TopView.GetEditWindow;
{$ENDIF}
if not Assigned(EditWindow) or not Assigned(EditWindow.Form) then
Exit;
Lib := GetModuleHandle(SStartPageIDE);
if Lib = 0 then
Exit;
OpenNewURLModule := GetProcAddress(Lib, SOpenNewURLModule);
if @OpenNewURLModule <> nil then
OpenNewURLModule(URL, EditWindow.Form);
end;
end;
Remaining cons:
- it's still a hack
- it's still hard-coded, for Delphi XE (Unicode) and Delphi 2007 (ANSI)
- it still does nothing if there is no edit window
Perhaps you can use this as a start if you need compatibility for other versions.
这篇关于欢迎页面浏览器如何从OTA包向导中导航到一些URI?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!