昏
存在版本问题
Flash没有遵守COM接口规则
D:\WINDOWS\system32\Macromed\Flash\flash.ocx
[
uuid(D27CDB6B-AE6D-11CF-96B8-444553540000),
version(1.0),
helpstring("Shockwave Flash")
]
library ShockwaveFlashObjects
...{
[
odl,
uuid(D27CDB6C-AE6D-11CF-96B8-444553540000),
helpstring("Shockwave Flash"),
dual,
oleautomation
]
interface IShockwaveFlash : IDispatch ...{
[id(0xfffffdf3), propget, helpstring("property ReadyState")]
HRESULT ReadyState([out, retval] long* pVal);
[id(0x0000007c), propget, helpstring("property TotalFrames")]
HRESULT TotalFrames([out, retval] long* pVal);
[id(0x0000007d), propget, helpstring("property Playing")]
HRESULT Playing([out, retval] VARIANT_BOOL* pVal);
[id(0x0000007d), propput, helpstring("property Playing")]
HRESULT Playing([in] VARIANT_BOOL pVal);
……
[id(0x0000009f), propget, helpstring("property SWRemote")]
HRESULT SWRemote([out, retval] BSTR* pVal);
[id(0x0000009f), propput, helpstring("property SWRemote")]
HRESULT SWRemote([in] BSTR pVal);
[id(0x000000aa), propget, helpstring("property FlashVars")]
HRESULT FlashVars([out, retval] BSTR* pVal);
[id(0x000000aa), propput, helpstring("property FlashVars")]
HRESULT FlashVars([in] BSTR pVal);
[id(0x000000ab), propget, helpstring("property AllowScriptAccess")]
HRESULT AllowScriptAccess([out, retval] BSTR* pVal);
[id(0x000000ab), propput, helpstring("property AllowScriptAccess")]
HRESULT AllowScriptAccess([in] BSTR pVal);
};
D:\WINDOWS\system32\Macromed\Flash\Flash8.ocx
[
uuid(D27CDB6B-AE6D-11CF-96B8-444553540000),
version(1.0),
helpstring("Shockwave Flash")
]
library ShockwaveFlashObjects
...{
// TLib : // TLib : OLE Automation : {00020430-0000-0000-C000-000000000046}
importlib("STDOLE2.TLB");
// Forward declare all types defined in this typelib
interface IShockwaveFlash;
dispinterface _IShockwaveFlashEvents;
interface IFlashFactory;
interface IFlashObjectInterface;
interface IDispatchEx;
interface IServiceProvider;
[
odl,
uuid(D27CDB6C-AE6D-11CF-96B8-444553540000),
helpstring("Shockwave Flash"),
dual,
oleautomation
]
interface IShockwaveFlash : IDispatch ...{
[id(0xfffffdf3), propget, helpstring("property ReadyState")]
HRESULT ReadyState([out, retval] long* pVal);
[id(0x0000007c), propget, helpstring("property TotalFrames")]
HRESULT TotalFrames([out, retval] long* pVal);
[id(0x0000007d), propget, helpstring("property Playing")]
HRESULT Playing([out, retval] VARIANT_BOOL* pVal);
[id(0x0000007d), propput, helpstring("property Playing")]
HRESULT Playing([in] VARIANT_BOOL pVal);
……
[id(0x0000009f), propget, helpstring("property SWRemote")]
HRESULT SWRemote([out, retval] BSTR* pVal);
[id(0x0000009f), propput, helpstring("property SWRemote")]
HRESULT SWRemote([in] BSTR pVal);
[id(0x000000aa), propget, helpstring("property FlashVars")]
HRESULT FlashVars([out, retval] BSTR* pVal);
[id(0x000000aa), propput, helpstring("property FlashVars")]
HRESULT FlashVars([in] BSTR pVal);
[id(0x000000ab), propget, helpstring("property AllowScriptAccess")]
HRESULT AllowScriptAccess([out, retval] BSTR* pVal);
[id(0x000000ab), propput, helpstring("property AllowScriptAccess")]
HRESULT AllowScriptAccess([in] BSTR pVal);
[id(0x000000be), propget, helpstring("property MovieData")]
HRESULT MovieData([out, retval] BSTR* pVal);
[id(0x000000be), propput, helpstring("property MovieData")]
HRESULT MovieData([in] BSTR pVal);
[id(0x000000bf), propget, helpstring("property inline-data")]
HRESULT InlineData([out, retval] IUnknown** ppIUnknown);
[id(0x000000bf), propput, helpstring("property inline-data")]
HRESULT InlineData([in] IUnknown* ppIUnknown);
[id(0x000000c0), propget, helpstring("property SeamlessTabbing")]
HRESULT SeamlessTabbing([out, retval] VARIANT_BOOL* pVal);
[id(0x000000c0), propput, helpstring("property SeamlessTabbing")]
HRESULT SeamlessTabbing([in] VARIANT_BOOL pVal);
[id(0x000000c1), helpstring("method EnforceLocalSecurity")]
HRESULT EnforceLocalSecurity();
[id(0x000000c2), propget, helpstring("property Profile")]
HRESULT Profile([out, retval] VARIANT_BOOL* pVal);
[id(0x000000c2), propput, helpstring("property Profile")]
HRESULT Profile([in] VARIANT_BOOL pVal);
[id(0x000000c3), propget, helpstring("property ProfileAddress")]
HRESULT ProfileAddress([out, retval] BSTR* pVal);
[id(0x000000c3), propput, helpstring("property ProfileAddress")]
HRESULT ProfileAddress([in] BSTR pVal);
[id(0x000000c4), propget, helpstring("property ProfilePort")]
HRESULT ProfilePort([out, retval] long* pVal);
[id(0x000000c4), propput, helpstring("property ProfilePort")]
HRESULT ProfilePort([in] long pVal);
[id(0x000000c6), helpstring("method Call")]
HRESULT CallFunction(
[in] BSTR request,
[out, retval] BSTR* response);
[id(0x000000c7), helpstring("method SetReturnValue")]
HRESULT SetReturnValue([in] BSTR returnValue);
[id(0x000000c8), helpstring("method DisableLocalSecurity")]
HRESULT DisableLocalSecurity();
};
也就是说存在三个版本:
1)我机子上的flash.ocx
2)你机子上的flash.ocx
3)我机子上的Flash8.ocx
2)比1)多出来了:
[id(0x000000be), propget, helpstring("property MovieData")]
HRESULT MovieData([out, retval] BSTR* pVal);
[id(0x000000be), propput, helpstring("property MovieData")]
HRESULT MovieData([in] BSTR pVal);
[id(0x000000bf), propget, helpstring("property inline-data")]
HRESULT InlineData([out, retval] IUnknown** ppIUnknown);
[id(0x000000bf), propput, helpstring("property inline-data")]
HRESULT InlineData([in] IUnknown* ppIUnknown);
[id(0x000000c0), propget, helpstring("property SeamlessTabbing")]
HRESULT SeamlessTabbing([out, retval] VARIANT_BOOL* pVal);
[id(0x000000c0), propput, helpstring("property SeamlessTabbing")]
HRESULT SeamlessTabbing([in] VARIANT_BOOL pVal);
3)比2)多出来了:
[id(0x000000c1), helpstring("method EnforceLocalSecurity")]
HRESULT EnforceLocalSecurity();
[id(0x000000c2), propget, helpstring("property Profile")]
HRESULT Profile([out, retval] VARIANT_BOOL* pVal);
[id(0x000000c2), propput, helpstring("property Profile")]
HRESULT Profile([in] VARIANT_BOOL pVal);
[id(0x000000c3), propget, helpstring("property ProfileAddress")]
HRESULT ProfileAddress([out, retval] BSTR* pVal);
[id(0x000000c3), propput, helpstring("property ProfileAddress")]
HRESULT ProfileAddress([in] BSTR pVal);
[id(0x000000c4), propget, helpstring("property ProfilePort")]
HRESULT ProfilePort([out, retval] long* pVal);
[id(0x000000c4), propput, helpstring("property ProfilePort")]
HRESULT ProfilePort([in] long pVal);
[id(0x000000c6), helpstring("method Call")]
HRESULT CallFunction(
[in] BSTR request,
[out, retval] BSTR* response);
[id(0x000000c7), helpstring("method SetReturnValue")]
HRESULT SetReturnValue([in] BSTR returnValue);
[id(0x000000c8), helpstring("method DisableLocalSecurity")]
HRESULT DisableLocalSecurity();
既然micromedia不遵守游戏规则,就不玩vtable了,不过根据种种迹象看来,micromedia公司对这种结果好象是有意为之.
Option Explicit
Private Declare Function SendMessage()Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Const WM_USER = &H400
Private Const EM_GETOLEINTERFACE = (WM_USER + 60)
Public Enum reCharPosEnum reCharPos
reSelection = -1
End Enum
Public Enum reObjectAspectEnum reObjectAspect
reObjectAspectContent = DVASPECT_CONTENT
reObjectAspectIcon = DVASPECT_ICON
End Enum
Public Function AddClass()Function AddClass(hWnd As Long, ObjIUnknown As stdole.IUnknown, _
Optional ByVal CharPos As Long = reSelection, _
Optional ByVal InitialAspect As reObjectAspect = reObjectAspectContent) As OleObject
Dim OleObject As olelib.IOleObject
Dim Storage As olelib.IStorage
Dim ClientSite As olelib.IOleClientSite
Dim VMSG As olelib.MSG
Dim tRECT As olelib.RECT
Dim tOUIIO As olelib.OLEUIINSERTOBJECT
Dim REOBJ As olelib.REOBJECT
Dim CLSID As olelib.UUID
Dim hMFPict As Long
Dim RichEditOle As IRichEditOle
SendMessage hWnd, EM_GETOLEINTERFACE, 0&, RichEditOle
Set ClientSite = RichEditOle.GetClientSite
Set Storage = StgCreateDocfile(vbNullString, STGM_CREATE Or STGM_READWRITE Or STGM_DELETEONRELEASE Or STGM_SHARE_EXCLUSIVE)
Set OleObject = ObjIUnknown
OleObject.GetUserClassID CLSID
On Error Resume Next
If hMFPict = 0 Then hMFPict = OleGetIconOfClass(CLSID, vbNullString, 1)
If Err.Number <> 0 Then InitialAspect = reObjectAspectContent
On Error GoTo 0
OleSetContainedObject ObjIUnknown, 1
With REOBJ
.cbStruct = Len(REOBJ)
LSet .CLSID = CLSID
.DVASPECT = InitialAspect
.cp = CharPos
.dwFlags = REO_DYNAMICSIZE Or REO_RESIZABLE
Set .pStg = Storage
Set .polesite = ClientSite
Set .poleobj = ObjIUnknown
End With
RichEditOle.InsertObject REOBJ
Set OleObject = Nothing
Set ClientSite = Nothing
Set Storage = Nothing
SendMessage hWnd, &HF, 0, 0
End Function可以实现我上面说的功能,但是好像刷新有问题。
SendMessage hWnd, &HF, 0, 0 仅对动态GIF起作用,对wmp和flash无效。
刷新的问题可以这样:
public void UpdateObjects()
...{
int k = this.IRichEditOle.GetObjectCount();
for (int i = 0; i < k; i++)
...{
REOBJECT reoObject = new REOBJECT();
this.IRichEditOle.GetObject(i, reoObject,
GETOBJECTOPTIONS.REO_GETOBJ_ALL_INTERFACES);
if (reoObject.dwUser == 1)
...{
Point pt = this._richEdit.GetPositionFromCharIndex(reoObject.cp);
Rectangle rect = new Rectangle(pt, reoObject.sizel);
this._richEdit.Invalidate(rect, false); // repaint
}
}
}
者QueryInterface flash控件的IViewObjectEx接口,然后调用IViewObjectEx接口的draw方法实现自绘
dim mIViewObject as IViewObject
set mIViewObject=ObjIUnknown
如果不报错的话,说明QI成功,然后就可以调用draw方法
我明白为什么“只有一个Flash控件在刷新”了
这与OLE的设计有关
在位激活(inplace activate)是指:
当点击嵌入的对象时,宿主程序将控制权交给嵌入对象,激活嵌入对象
而嵌入对象没有激活时,宿主程序只维持该嵌入对象的静态图像
解决方法:按楼上的方法手动刷新RichEdit中的所有OLE对象
首先在窗体上画一个richtextbox控件,一个flash控件(这个flash控件没有用上,它是为程序中动态添加flash控件做准备的,事实上这是一种无奈的做法,原因是Licenses.Add方法对flash的progid不感兴趣,当然,你也可以通过其它途径解决这个问题),一个timer控件,一个按钮:
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。