Win32编程点滴 - 简单ActiveX控件的使用
2010-01-10 09:37:18 来源:WEB开发网接下来,在父窗口的窗口过程中,调用上面实现的函数,创建一个Flash控件:
IUnknown * g_pControl = NULL;//控件的指针
LRESULT CALLBACK WndProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
....
switch(message)
{
case WM_CREATE:
//Flash控件
hr = CreateAxControl (hWnd,L"ShockwaveFlash.ShockwaveFlash",&pControl,&pContainer);
if (SUCCESSED(hr))
{
VARIANT src;
src.vt = VT_BSTR;
src.bstrVal = SysAllocString (L"http://www.google.com/intl/en_ALL/images/logo.gif");
DispSetProperty(pControl,L"movie",&src);//这个函数的实现,请下载源代码
}
break;
case WM_SIZE:
{
//调 整控件的大小
RECT rcClient;
GetClientRect (hWnd,&rcClient);
IOleInPlaceObject * pInPlaceObject;
if (g_pControl &&
SUCCEEDED(g_pControl- >QueryInterface(IID_IOleInPlaceObject,(void**)&pInPlaceObject)))
{
pInPlaceObject->SetObjectRects(&rcClient,&rcClient);
pInPlaceObject->Release();
}
}
break;
}
....
}
下载源代码:files.cnblogs.com/Greatest/TestActiveX1.zip
更多精彩
赞助商链接