好像不行,因为IDocHostUIHandler接口是直接从IUnknow接口继承过来的,VB是不能编写这个接口
的。不过VB是可以调用用其他语言实现了这个接口的控件,像上文所说的微软的例子
http://download.microsoft.com/download/vc50pro/sample5/1/W9XNT4/EN-US/WBCustom.exe
就是用VC写的COM,然后用VB调用,VB在这些底层的编程上就没有优势啦!不过Delphi可以写这个
接口的,其实很简单,只要你有接口说明文件。这是embeddedWb控件中的接口说明,
IDocHostUIHandler = interface(IUnknown)
['{bd3f23c0-d43e-11cf-893b-00aa00bdce1a}']
function ShowContextMenu(const dwID: DWORD; const ppt: PPOINT;
const pcmdtReserved: IUnknown; const pdispReserved: IDispatch): HRESULT; stdcall;
function GetHostInfo(var pInfo: TDOCHOSTUIINFO): HRESULT; stdcall;
function ShowUI(const dwID: DWORD; const pActiveObject: IOleInPlaceActiveObject;
const pCommandTarget: IOleCommandTarget; const pFrame: IOleInPlaceFrame;
const pDoc: IOleInPlaceUIWindow): HRESULT; stdcall;
function HideUI: HRESULT; stdcall;
function UpdateUI: HRESULT; stdcall;
function EnableModeless(const fEnable: BOOL): HRESULT; stdcall;
function OnDocWindowActivate(const fActivate: BOOL): HRESULT; stdcall;
function OnFrameWindowActivate(const fActivate: BOOL): HRESULT; stdcall;
function ResizeBorder(const prcBorder: PRECT;
const pUIWindow: IOleInPlaceUIWindow;
const fRameWindow: BOOL): HRESULT; stdcall;
function TranslateAccelerator(const lpMsg: PMSG; const pguidCmdGroup: PGUID;
const nCmdID: DWORD): HRESULT; stdcall;
function GetOptionKeyPath(var pchKey: POLESTR; const dw: DWORD): HRESULT; stdcall;
function GetDropTarget(const pDropTarget: IDropTarget;
out ppDropTarget: IDropTarget): HRESULT; stdcall;
function GetExternal(out ppDispatch: IDispatch): HRESULT; stdcall;
function TranslateUrl(const dwTranslate: DWORD; const pchURLIn: POLESTR;
var ppchURLOut: POLESTR): HRESULT; stdcall;
function FilterDataObject(const pDO: IDataObject;
out ppDORet: IDataObject): HRESULT; stdcall;
end; // IDocHostUIHandler
然后是实现这个接口啦!
TDocHostUIHandler = calss (TInterfacedObject,IDocHostUIHandler)
public
ShowContextMenu......
然后实现这个接口就可以啦,这是关键,具体详情你得去查MSDN啦!
还有就是要实现ICustomDoc接口,这样你才能设置IDocHostUIHandler接口。