WTL对 Flash 控件的使用
来源:互联网 发布:小型学校网络设计 编辑:程序博客网 时间:2024/06/03 06:44
MFC和 WTL 对Flash 控件的使用,都差不多,以WTL为例进行说明:
1. 首先使用向导创建一个基于对话框的应用程序,然后在 在maindlg 创建之前加入 AtlAxWinInit(),
2. 在主对话框中增加 CAxWindow m_PlayerHostWnd;
CComPtr<IShockwaveFlash> m_FlashPlayer;
3. 在资源中增加一个Flash控件,右键菜单,Insert ActiveX control 的哪项,然后进行拖放大小。
4.
// Load the flash player
m_PlayerHostWnd = GetDlgItem( IDC_SHOCKWAVEFLASH_PLAYER );
LRESULT lResult = m_PlayerHostWnd.QueryControl( &m_FlashPlayer );
if ( FAILED( lResult ) )
{
MessageBox(L"Can not Load the active X");
return FALSE;
}
如下的语句可以初始化完毕了,
5. _bstr_t strMovieName( strPath.GetBuffer(strPath.GetLength()) );
lResult = m_FlashPlayer->put_Movie( strMovieName );
就是播放了。
6. 增加Flash的Event响应,那么就要将自己的类派生自IDispEventImpl<IDC_SHOCKWAVEFLASH_PLAYER,CMainDlg>
class CMainDlg : public CAxDialogImpl<CMainDlg>,
public IDispEventImpl<IDC_SHOCKWAVEFLASH_PLAYER,CMainDlg>
7. 增加如下代码在 LRESULT OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) 中
AtlAdviseSinkMap( this, true );
8. 使用
BEGIN_SINK_MAP(CMainDlg)
SINK_ENTRY(IDC_SHOCKWAVEFLASH_PLAYER, 150, HandleFSCommand)
SINK_ENTRY(IDC_SHOCKWAVEFLASH_PLAYER, 1958, OnFlashPlayerProgress)
END_SINK_MAP()
建立 事件处理分配表,并且实现响应的函数。
9. 一定要记得在关闭窗口的时候,或者窗口类销毁的时候,调用AtlAdviseSinkMap( this, false);
// MainDlg.h : interface of the CMainDlg class///////////////////////////////////////////////////////////////////////////////#pragma once#include <atlstr.h>#include "resource.h"class CMainDlg : public CAxDialogImpl<CMainDlg>,public IDispEventImpl<IDC_SHOCKWAVEFLASH_PLAYER,CMainDlg>{public:enum { IDD = IDD_MAINDLG };BEGIN_MSG_MAP(CMainDlg)MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)COMMAND_ID_HANDLER(ID_APP_ABOUT, OnAppAbout)COMMAND_ID_HANDLER(IDOK, OnOK)COMMAND_ID_HANDLER(IDCANCEL, OnCancel)END_MSG_MAP()BEGIN_SINK_MAP(CMainDlg)SINK_ENTRY(IDC_SHOCKWAVEFLASH_PLAYER, 150, HandleFSCommand)SINK_ENTRY(IDC_SHOCKWAVEFLASH_PLAYER, 1958, OnFlashPlayerProgress)END_SINK_MAP()CAxWindow m_PlayerHostWnd;CComPtr<IShockwaveFlash> m_FlashPlayer;// Handler prototypes (uncomment arguments if needed)://LRESULT MessageHandler(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)//LRESULT CommandHandler(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)//LRESULT NotifyHandler(int /*idCtrl*/, LPNMHDR /*pnmh*/, BOOL& /*bHandled*/)LRESULT OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/){// center the dialog on the screenCenterWindow();// set iconsHICON hIcon = (HICON)::LoadImage(_Module.GetResourceInstance(), MAKEINTRESOURCE(IDR_MAINFRAME), IMAGE_ICON, ::GetSystemMetrics(SM_CXICON), ::GetSystemMetrics(SM_CYICON), LR_DEFAULTCOLOR);SetIcon(hIcon, TRUE);HICON hIconSmall = (HICON)::LoadImage(_Module.GetResourceInstance(), MAKEINTRESOURCE(IDR_MAINFRAME), IMAGE_ICON, ::GetSystemMetrics(SM_CXSMICON), ::GetSystemMetrics(SM_CYSMICON), LR_DEFAULTCOLOR);SetIcon(hIconSmall, FALSE);// Load the flash player m_PlayerHostWnd = GetDlgItem( IDC_SHOCKWAVEFLASH_PLAYER );LRESULT lResult = m_PlayerHostWnd.QueryControl( &m_FlashPlayer );if ( FAILED( lResult ) ){MessageBox(L"Can not Load the active X");return FALSE;}TCHAR szBuffer[1024] = {0};GetModuleFileName((HMODULE)&__ImageBase, szBuffer, sizeof(szBuffer) / sizeof(szBuffer[0]));TCHAR *pFind = _tcsrchr( szBuffer, '\\');*(pFind + 1) = 0;CString strPath = szBuffer;strPath.Append( L"preview7us.swf" );_bstr_t strMovieName( strPath.GetBuffer(strPath.GetLength()) );strPath.ReleaseBuffer( -1 );/*DispEventAdvise( m_FlashPlayer );*/AtlAdviseSinkMap( this, true );lResult = m_FlashPlayer->put_Movie( strMovieName );if ( FAILED( lResult) ){MessageBox(L"can not open the flash");}m_FlashPlayer->Stop();m_FlashPlayer->Play();return TRUE;}LRESULT OnAppAbout(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/){CSimpleDialog<IDD_ABOUTBOX, FALSE> dlg;dlg.DoModal();return 0;}LRESULT OnOK(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/){if ( !!m_FlashPlayer ){m_FlashPlayer->Stop();}EndDialog(wID);return 0;}LRESULT OnCancel(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/){if ( !!m_FlashPlayer ){m_FlashPlayer->Stop();}EndDialog(wID);return 0;} void __stdcall HandleFSCommand(BSTR command, BSTR args){}void __stdcall OnFlashPlayerProgress(long percentDone){}};
- WTL对 Flash 控件的使用
- 使用WTL自绘控件
- WTL的SDI中Edit控件无法使用快捷键原因
- 自己对WTL使用中一个小问题的解决方法
- duilib flash控件的使用
- wtl的CTreeViewCtrl使用
- WTL的安装和使用
- WTL中CListViewCtrl的使用
- WTL控件的自画操作
- WTL 通用控件的封装类
- WTL中封装的控件类
- 自绘WTL的CComboBox控件
- Flash控件使用参考手册
- Flash控件fusionChart使用
- WTL使用
- Flash 控件的安装
- 在WTL中实现Spin control控件(使用SetBuddy)
- 在WTL中实现Spin control控件(使用SetBuddy)
- 街道问题(way.pas/c/cpp)
- 从本地电子商务中走出来,6个很好的O2O模式解析
- 一周简报(Dojo及信息报送业务)
- Android开发音乐播放器
- java 解决 汉诺塔问题(递归算法)
- WTL对 Flash 控件的使用
- 【转】大学生应该知道的经管知识
- 嵌套母板页简单应用
- usaco 欧拉路
- 它看起来是一张图片,实际上是一个压缩包
- Linux su 和 sudo
- C# 中string的最大长度是多少
- 【转】找回你删掉并清空回收站的东西
- C# 操作Excel是遇到的80070005错误-解决方法