📄 flashplayview.cpp
字号:
// FlashPlayView.cpp : implementation of the CFlashPlayView class
//
#include "stdafx.h"
#include "FlashPlay.h"
#include "FlashPlayDoc.h"
#include "FlashPlayView.h"
#include "mainfrm.h"
#include "MenuEx\BCMenu.h"
#include <Mmsystem.h>
#include < stdarg.h >
#include "OptionSet.h"
#include "registry\registry.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CFlashPlayView
IMPLEMENT_DYNCREATE(CFlashPlayView, CView)
BEGIN_MESSAGE_MAP(CFlashPlayView, CView)
//{{AFX_MSG_MAP(CFlashPlayView)
ON_WM_CREATE()
ON_COMMAND(ID_PLAY_PLAY, OnPlayPlay)
ON_UPDATE_COMMAND_UI(ID_PLAY_PLAY, OnUpdatePlayPlay)
ON_COMMAND(ID_PLAY_PAUSE, OnPlayPause)
ON_UPDATE_COMMAND_UI(ID_PLAY_PAUSE, OnUpdatePlayPause)
ON_COMMAND(ID_PLAY_STOP, OnPlayStop)
ON_UPDATE_COMMAND_UI(ID_PLAY_STOP, OnUpdatePlayStop)
ON_COMMAND(ID_PLAY_FORWARD, OnPlayForward)
ON_UPDATE_COMMAND_UI(ID_PLAY_FORWARD, OnUpdatePlayForward)
ON_COMMAND(ID_PLAY_BACK, OnPlayBack)
ON_UPDATE_COMMAND_UI(ID_PLAY_BACK, OnUpdatePlayBack)
ON_WM_SIZE()
ON_COMMAND(ID_VIEW_RBTNMENU, OnViewRbtnmenu)
ON_UPDATE_COMMAND_UI(ID_VIEW_RBTNMENU, OnUpdateViewRbtnmenu)
ON_WM_CLOSE()
ON_WM_TIMER()
ON_COMMAND(ID_TOOLS_OPTION, OnToolsOption)
ON_WM_CONTEXTMENU()
ON_WM_KEYUP()
//}}AFX_MSG_MAP
// 用 OnMsgChangPosition 函式处理自定义消息 WM_USER_CHANG_POSITION
ON_MESSAGE(WM_USER_CHANG_POSITION,OnMsgChangPosition)
END_MESSAGE_MAP()
BEGIN_EVENTSINK_MAP(CFlashPlayView,CView)
//{{AFX_EVENTSINK_MAP(CFlashPlayView)
ON_EVENT(CFlashPlayView, FLASHID, 150 /* FSCommand */, OnFSCommandFlash, VTS_BSTR VTS_BSTR)
//}}AFX_EVENTSINK_MAP
END_EVENTSINK_MAP()
/////////////////////////////////////////////////////////////////////////////
// CFlashPlayView construction/destruction
CFlashPlayView::CFlashPlayView()
{
// TODO: add construction code here
m_bEnableRBtn = TRUE;
m_bMovieExist = FALSE;
m_bIsPlaying = FALSE;
// MENUEX_ADD - Context menu is initialized with no parent window
//m_menuContext.Initialize(IDR_MENU_POPUP, NULL);
}
CFlashPlayView::~CFlashPlayView()
{
}
BOOL CFlashPlayView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
cs.dwExStyle |= WS_EX_CLIENTEDGE;
cs.style &= ~WS_BORDER;
cs.lpszClass = AfxRegisterWndClass(CS_HREDRAW|CS_VREDRAW|CS_DBLCLKS,
::LoadCursor(NULL, IDC_ARROW), HBRUSH(COLOR_WINDOWTEXT), NULL);
return CView::PreCreateWindow(cs);
}
/////////////////////////////////////////////////////////////////////////////
// CFlashPlayView drawing
void CFlashPlayView::OnDraw(CDC* pDC)
{
CFlashPlayDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
//m_flash.LoadMovie (0,pDoc->GetFileName());
}
/////////////////////////////////////////////////////////////////////////////
// CFlashPlayView diagnostics
#ifdef _DEBUG
void CFlashPlayView::AssertValid() const
{
CView::AssertValid();
}
void CFlashPlayView::Dump(CDumpContext& dc) const
{
CView::Dump(dc);
}
CFlashPlayDoc* CFlashPlayView::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CFlashPlayDoc)));
return (CFlashPlayDoc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CFlashPlayView message handlers
int CFlashPlayView::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CView::OnCreate(lpCreateStruct) == -1)
return -1;
m_nTimer = SetTimer(1, 100, 0);
CRect rect;
GetClientRect( &rect );
m_flash.Create(NULL,WS_CHILD|WS_VISIBLE|AFX_WS_DEFAULT_VIEW,
CRect(0, 0,750, 680),this,FLASHID);
//使flash窗口显示到视的满屏。
m_flash.MoveWindow( &rect );
//使得紧凑模式的设置无效
m_flash.EnableCompactMode(FALSE);
char * strSection = "Option";
char * strStringFileAssoc = "File Type Associate";
char * strIntEnablePopup = "Enable popup menu";
char * strIntHideMouse = "Hide Mouse pointer while Full Screen";
char * strIntHideTime = "Hide time";
char * strIntOnTop = "Always on top";
CWinApp* pApp = AfxGetApp();
m_bFileType = pApp->GetProfileInt(strSection, strStringFileAssoc, 0);
m_bEnableRBtn = pApp->GetProfileInt(strSection, strIntEnablePopup, 0);
m_bHideMouse = pApp->GetProfileInt(strSection, strIntHideMouse, 1);
m_nEditHideTime = pApp->GetProfileInt(strSection, strIntHideTime, 10);
m_bOnTop = pApp->GetProfileInt(strSection, strIntOnTop, 0);
m_flash.SetMenuEnable(m_bEnableRBtn);
// TODO: Add your specialized creation code here
return 0;
}
void CFlashPlayView::OnPlayPlay()
{
// TODO: Add your command handler code here
m_flash.Play();
m_bIsPlaying = TRUE;
}
void CFlashPlayView::OnUpdatePlayPlay(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
BOOL bPlaying = m_flash.GetReadyState()>3 && !m_flash.IsPlaying();
pCmdUI->Enable( bPlaying );
}
void CFlashPlayView::OnPlayPause()
{
// TODO: Add your command handler code here
m_flash.StopPlay();
m_bIsPlaying = FALSE;
}
void CFlashPlayView::OnUpdatePlayPause(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
BOOL bPlaying = m_flash.GetReadyState()>3 && m_flash.IsPlaying();
pCmdUI->Enable( bPlaying );
m_bIsPlaying = bPlaying;
}
void CFlashPlayView::OnPlayStop()
{
// TODO: Add your command handler code here
m_flash.StopPlay();
m_flash.Rewind();
m_bIsPlaying = FALSE;
}
void CFlashPlayView::OnUpdatePlayStop(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
pCmdUI->Enable(m_flash.GetReadyState()>3 && m_flash.IsPlaying());
}
void CFlashPlayView::OnPlayForward()
{
// TODO: Add your command handler code here
m_flash.Forward();
}
void CFlashPlayView::OnUpdatePlayForward(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
pCmdUI->Enable(m_flash.GetReadyState()>3 &&
m_flash.CurrentFrame()<m_flash.GetTotalFrames());
}
void CFlashPlayView::OnPlayBack()
{
// TODO: Add your command handler code here
m_flash.Back();
}
void CFlashPlayView::OnUpdatePlayBack(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
pCmdUI->Enable(m_flash.GetReadyState()>3
&& !(m_flash.CurrentFrame()==1));
}
void CFlashPlayView::OnSize(UINT nType, int cx, int cy)
{
CView::OnSize(nType, cx, cy);
// TODO: Add your message handler code here
// 让 Flash 窗口占满整个客户区
m_flash.SetWindowPos(NULL,0,0,cx,cy,SWP_NOZORDER|SWP_NOMOVE);
}
afx_msg void CFlashPlayView::OnFSCommandFlash(LPCTSTR command, LPCTSTR args)
{
// 处理FLASH控件里影片发送的消息,命令标识字符串由特定影片决定
// 如果影片里有"退出"按钮且设定的命令字符串为"quit",则执行下面5行代码
//if(strcmp(command,"quit")==0)
//{
// m_flash.Stop();
// AfxGetMainWnd()->PostMessage(WM_CLOSE);
//}
//else if(strcmp(command,"SetupPath")==0)
// DoRun( args );
//else if(strcmp(command,"OpenPath")==0)
// DoExplore( args );
//else
//{
// Execute a application
// Path = szWorkPath+path;
// ::ShellExecute(NULL,
// NULL,//ContentInfo[sel].szCmdOperation,
// Path,
// NULL,
// NULL,
// SW_SHOWNORMAL);
//}
}
void CFlashPlayView::OnViewRbtnmenu()
{
// TODO: Add your command handler code here
m_bEnableRBtn = !m_bEnableRBtn;
m_flash.SetMenuEnable(m_bEnableRBtn);
}
void CFlashPlayView::OnUpdateViewRbtnmenu(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
pCmdUI->SetCheck(m_bEnableRBtn);
}
void CFlashPlayView::OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint)
{
// TODO: Add your specialized code here and/or call the base class
// set the main window is on top of all window on desktop
CWinApp* pApp = AfxGetApp();
if( m_bOnTop ) ::SetWindowPos( pApp->m_pMainWnd->GetSafeHwnd(),
HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE );
else ::SetWindowPos( pApp->m_pMainWnd->GetSafeHwnd(),
HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE );
CString strFileName = GetDocument()->GetFileName();
if( strFileName.IsEmpty() )
{
return;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -