?? flashplayer1.cpp
字號(hào):
// FlashPlayer1.cpp : implementation file
//
#include "stdafx.h"
#include "flashPlayer.h"
#include "FlashPlayer1.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
extern CFlashPlayer *m_pflashplayer;
CFlashPlayer::CFlashPlayer(CWnd* pParent /*=NULL*/)
: CDialog(CFlashPlayer::IDD, pParent)
{
//{{AFX_DATA_INIT(CFlashPlayer)
//}}AFX_DATA_INIT
}
void CFlashPlayer::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CFlashPlayer)
DDX_Control(pDX, IDC_SHOCKWAVEFLASH, m_flash);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CFlashPlayer, CDialog)
//{{AFX_MSG_MAP(CFlashPlayer)
ON_BN_CLICKED(IDC_OPEN, OnOpen)
ON_BN_CLICKED(IDC_PLAY, OnPlay)
ON_BN_CLICKED(IDC_SHORTSTOP, OnShortstop)
ON_BN_CLICKED(IDC_STOP, OnStop)
ON_BN_CLICKED(IDC_PRE, OnPre)
ON_BN_CLICKED(IDC_NEXT, OnNext)
ON_BN_CLICKED(IDC_FULLSCREEN, OnFullscreen)
ON_WM_SIZE()
ON_WM_NCMOUSEMOVE()
ON_WM_DESTROY()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CFlashPlayer message handlers
void CFlashPlayer::OnOpen()
{
char szFilters[]="flashType Files (*.swf)|*.swf|All file(*.*)|*.*||";
CFileDialog fileDlg(TRUE,"flash", "*.swf",OFN_FILEMUSTEXIST| OFN_HIDEREADONLY,szFilters, this);
if(fileDlg.DoModal()==IDOK)
{
if(m_flash.GetMovie()!="")
m_flash.SetMovie("http://");
m_flash.SetMovie(fileDlg.GetPathName());
}
}
void CFlashPlayer::OnPlay()
{
m_flash.Play();
}
void CFlashPlayer::OnShortstop()
{
m_flash.Stop();
}
void CFlashPlayer::OnStop()
{
m_flash.Rewind();
m_flash.Stop();
}
void CFlashPlayer::OnPre()
{
long CurFrame;
CurFrame=m_flash.CurrentFrame();
if(CurFrame>=20)
CurFrame-=20;
else
CurFrame=0;
m_flash.GotoFrame(CurFrame);
}
void CFlashPlayer::OnNext()
{
long CurFrame,FrameNum;
CurFrame=m_flash.CurrentFrame();
FrameNum=m_flash.GetTotalFrames();
if(CurFrame+20<=FrameNum)
CurFrame+=20;
else
CurFrame=FrameNum;
m_flash.GotoFrame(CurFrame);
}
void CFlashPlayer::OnFullscreen()
{
::SendMessage(m_hWnd,WM_SYSCOMMAND,SC_MAXIMIZE,0);
CRect rt;
GetClientRect(&rt);
m_flash.MoveWindow(&rt);
SetSubWndVisible(FALSE);
}
void CFlashPlayer::OnSize(UINT nType, int cx, int cy)
{
CDialog::OnSize(nType, cx, cy);
if(nType==SIZE_RESTORED)
if(m_flash.m_hWnd)
{
m_flash.MoveWindow(10,10,cx-20,cy-50);
SetSubWndVisible(TRUE);
}
}
void CFlashPlayer::SetSubWndVisible(BOOL BVisible)
{
int ShowFlags;
if(BVisible)
ShowFlags=SW_SHOW;
else
ShowFlags=SW_HIDE;
CWnd *pWnd=GetDlgItem(IDC_OPEN);
pWnd->ShowWindow(ShowFlags);
pWnd=GetDlgItem(IDC_PLAY);
pWnd->ShowWindow(ShowFlags);
pWnd=GetDlgItem(IDC_SHORTSTOP);
pWnd->ShowWindow(ShowFlags);
pWnd=GetDlgItem(IDC_STOP);
pWnd->ShowWindow(ShowFlags);
pWnd=GetDlgItem(IDC_PRE);
pWnd->ShowWindow(ShowFlags);
pWnd=GetDlgItem(IDC_NEXT);
pWnd->ShowWindow(ShowFlags);
pWnd=GetDlgItem(IDC_FULLSCREEN);
pWnd->ShowWindow(ShowFlags);
}
BOOL CFlashPlayer::PreTranslateMessage(MSG* pMsg)
{
//截獲ESC和回車鍵,避免按下此鍵時(shí)關(guān)閉對(duì)話框
if (pMsg->message == WM_KEYDOWN)
{
if(pMsg->wParam==VK_ESCAPE)
::SendMessage(m_hWnd,WM_SYSCOMMAND,SC_RESTORE,0);
if(pMsg->wParam==VK_RETURN)
{
return true;
}
}
return CDialog::PreTranslateMessage(pMsg);
}
void CFlashPlayer::OnDestroy()
{
CDialog::OnDestroy();
delete this;
m_pflashplayer=NULL;
}
//-----------------------------------------------
//------------------ 邊框繪制 -------------------
void CFlashPlayer::DrawFrameBar()
{
if (m_hWnd)
{
CWindowDC *pDC=new CWindowDC(this);
CBrush Brush(RGB(100,100,250));
CBrush* pOldBrush = pDC->SelectObject(&Brush);
CRect rtWnd, rtTitle, rtButtons;
GetWindowRect(&rtWnd);
//取得標(biāo)題欄的位置
rtTitle.left = GetSystemMetrics(SM_CXFRAME);
rtTitle.top = GetSystemMetrics(SM_CYFRAME);
rtTitle.right = rtWnd.right - rtWnd.left - GetSystemMetrics(SM_CXFRAME);
rtTitle.bottom = rtTitle.top + GetSystemMetrics(SM_CYSIZE);
CPoint point;
//填充頂部框架
point.x = rtWnd.Width();
point.y = GetSystemMetrics(SM_CYSIZE) + GetSystemMetrics(SM_CYFRAME);
pDC->PatBlt(0, 0, point.x, point.y, PATCOPY);
//填充左側(cè)框架
point.x = GetSystemMetrics(SM_CXFRAME) + 1;
point.y = rtWnd.Height();
pDC->PatBlt(0, 0, point.x, point.y, PATCOPY);
//填充底部框架
point.x = rtWnd.Width();
point.y = GetSystemMetrics(SM_CYFRAME) + 1;
pDC->PatBlt(0, rtWnd.Height()-point.y, point.x, point.y, PATCOPY);
//填充右側(cè)框架
point.x = GetSystemMetrics(SM_CXFRAME) + 1;
point.y = rtWnd.Height();
pDC->PatBlt(rtWnd.Width()-point.x, 0, point.x, point.y, PATCOPY);
//重畫caption
int nOldMode = pDC->SetBkMode(TRANSPARENT);
COLORREF clOldText=pDC->SetTextColor(RGB(255, 255, 255));
pDC->SelectStockObject(SYSTEM_FIXED_FONT);
rtTitle.top+=2;
CString m_strTitle;
GetWindowText(m_strTitle);
pDC->DrawText(m_strTitle, &rtTitle, DT_LEFT);
pDC->SetBkMode(nOldMode);
pDC->SetTextColor(clOldText);
//準(zhǔn)備畫XP風(fēng)格按鈕
CBitmap* pBitmap = new CBitmap;
CBitmap* pOldBitmap;
CDC* pDisplayMemDC=new CDC;
pDisplayMemDC->CreateCompatibleDC(pDC);
//重畫關(guān)閉button
rtButtons.left = rtTitle.right - 19;
rtButtons.top = rtTitle.top;
rtButtons.right = rtButtons.left + 19;
rtButtons.bottom = rtButtons.top + 19;
pBitmap->LoadBitmap(IDB_EXIT);
pOldBitmap=(CBitmap*)pDisplayMemDC->SelectObject(pBitmap);
pDC->BitBlt(rtButtons.left, rtButtons.top, rtButtons.Width(), rtButtons.Height(), pDisplayMemDC, 0, 0, SRCCOPY);
pDisplayMemDC->SelectObject(pOldBitmap);
pBitmap->DeleteObject();
//Draw Close Button
ReleaseDC(pDisplayMemDC);
delete pDisplayMemDC;
pDC->SelectObject(pOldBrush);
if(pDC)
pDC->DeleteDC();
}
}
//移動(dòng)到CLOSE BUTTON上時(shí)進(jìn)行繪制
void CFlashPlayer::OnNcMouseMove(UINT nHitTest,CPoint point)
{
CDialog::OnNcMouseMove(nHitTest,point);
if(nHitTest&HTCLOSE)
{
CWindowDC *pDC=new CWindowDC(this);
CRect rtWnd, rtTitle, rtButtons;
GetWindowRect(&rtWnd);
//取得標(biāo)題欄的位置
rtTitle.left = GetSystemMetrics(SM_CXFRAME);
rtTitle.top = GetSystemMetrics(SM_CYFRAME);
rtTitle.right = rtWnd.right - rtWnd.left - GetSystemMetrics(SM_CXFRAME);
rtTitle.bottom = rtTitle.top + GetSystemMetrics(SM_CYSIZE);
//準(zhǔn)備畫XP風(fēng)格按鈕
CBitmap* pBitmap = new CBitmap;
CBitmap* pOldBitmap;
CDC* pDisplayMemDC=new CDC;
pDisplayMemDC->CreateCompatibleDC(pDC);
//重畫關(guān)閉button
rtButtons.left = rtTitle.right - 19;
rtButtons.top = rtTitle.top;
rtButtons.right = rtButtons.left + 19;
rtButtons.bottom = rtButtons.top + 19;
pBitmap->LoadBitmap(IDB_EXIT);
pOldBitmap=(CBitmap*)pDisplayMemDC->SelectObject(pBitmap);
pDC->BitBlt(rtButtons.left, rtButtons.top, rtButtons.Width(), rtButtons.Height(), pDisplayMemDC, 0, 0, SRCCOPY);
pDisplayMemDC->SelectObject(pOldBitmap);
pBitmap->DeleteObject();
ReleaseDC(pDisplayMemDC);
delete pDisplayMemDC;
if(pDC)
pDC->DeleteDC();
}
}
LRESULT CFlashPlayer::DefWindowProc(UINT message, WPARAM wParam, LPARAM lParam)
{
LRESULT lrst=CDialog::DefWindowProc(message, wParam, lParam);
if (message==WM_NCPAINT||message==WM_NCACTIVATE ||message==WM_NCMOUSEMOVE)
{
DrawFrameBar();
}
return lrst;
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -