LaK*_*ven 26
这是我专门为您制定的解决方案......
从这里下载源代码,在Delphi中提取并加载包(我在Delphi XE中创建,但它将在任何版本中加载!你需要在XE之前版本的Project Options中更改单元输出路径) ...安装包.
在"帮助"菜单中,找到" 创建浏览器"并单击它.然后,这将创建并显示导航到我的博客的选项卡(出于示例的目的).
您可以轻松修改它以满足您的需求!帮助菜单项代码位于EditWizard.MenuItem.pas
,可以忽略不计!请注意,单击时它正在进行调用(BorlandIDEServices as IOTAEditorViewServices).ShowEditorView(CreateTab('http://www.simonjstuart.com'));
,这实际上是创建浏览器选项卡实例的!
浏览器选项卡的所有代码(包括其框架布局)都包含在内EditorWizard.Frame.pas
,这使得它很容易修改以满足您的需求!
该单元EditorWizard.Wizard.pas
包含将自定义浏览器选项卡注册到IDE所需的少量代码.
当然,您需要进行一些调整,但这肯定会成为您尝试做的事情的一个非常可接受的基础.
请享用 :)
如果你愿意使用这样的黑客:
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;
Run Code Online (Sandbox Code Playgroud)
缺点:
编辑:似乎可以重用现有的打开欢迎页面,以及使这个黑客兼容旧版本的Delphi.以下显示了两个备选方案:Delphi XE和Delphi 2007(两者似乎都在工作):
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;
Run Code Online (Sandbox Code Playgroud)
剩下的缺点:
如果您需要兼容其他版本,也许您可以将此作为开始.