📄 mfcflashview.cpp
字号:
// MFCFlashView.cpp : implementation of the CMFCFlashView class
//
#include "stdafx.h"
#include "MFCFlash.h"
#include "MFCFlashDoc.h"
#include "MFCFlashView.h"
#include <SHLWAPI.H>
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CMFCFlashView
IMPLEMENT_DYNCREATE(CMFCFlashView, CView)
BEGIN_MESSAGE_MAP(CMFCFlashView, CView)
//{{AFX_MSG_MAP(CMFCFlashView)
ON_WM_SIZE()
//}}AFX_MSG_MAP
// Standard printing commands
ON_COMMAND(ID_FILE_PRINT, CView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_DIRECT, CView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_PREVIEW, CView::OnFilePrintPreview)
END_MESSAGE_MAP()
BEGIN_EVENTSINK_MAP(CMFCFlashView, CView)
ON_EVENT(CMFCFlashView, AFX_IDW_PANE_FIRST, 150, FSCommondShockwave, VTS_BSTR VTS_BSTR)
END_EVENTSINK_MAP()
/////////////////////////////////////////////////////////////////////////////
// CMFCFlashView construction/destruction
CMFCFlashView::CMFCFlashView()
{
// TODO: add construction code here
}
CMFCFlashView::~CMFCFlashView()
{
}
BOOL CMFCFlashView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CView::PreCreateWindow(cs);
}
/////////////////////////////////////////////////////////////////////////////
// CMFCFlashView drawing
void CMFCFlashView::OnDraw(CDC* pDC)
{
CMFCFlashDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
}
/////////////////////////////////////////////////////////////////////////////
// CMFCFlashView printing
BOOL CMFCFlashView::OnPreparePrinting(CPrintInfo* pInfo)
{
// default preparation
return DoPreparePrinting(pInfo);
}
void CMFCFlashView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add extra initialization before printing
}
void CMFCFlashView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add cleanup after printing
}
/////////////////////////////////////////////////////////////////////////////
// CMFCFlashView diagnostics
#ifdef _DEBUG
void CMFCFlashView::AssertValid() const
{
CView::AssertValid();
}
void CMFCFlashView::Dump(CDumpContext& dc) const
{
CView::Dump(dc);
}
CMFCFlashDoc* CMFCFlashView::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CMFCFlashDoc)));
return (CMFCFlashDoc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CMFCFlashView message handlers
void CMFCFlashView::OnInitialUpdate()
{
CView::OnInitialUpdate();
// TODO: Add your specialized code here and/or call the base class
CHAR szPath[MAX_PATH];
memset(szPath, 0, sizeof(CHAR)*MAX_PATH);
m_wndFlash.Create(NULL, NULL, WS_CHILD|WS_VISIBLE, CRect(0, 0, 0, 0), this, AFX_IDW_PANE_FIRST);
GetCurrentDirectory(MAX_PATH, szPath);
StrCat(szPath, _T("\\add.swf"));
m_wndFlash.PutFlashFile(szPath);
m_wndFlash.Play();
}
void CMFCFlashView::OnSize(UINT nType, int cx, int cy)
{
CView::OnSize(nType, cx, cy);
// TODO: Add your message handler code here
if(m_wndFlash.GetSafeHwnd())
{
m_wndFlash.MoveWindow(0, 0, cx, cy);
}
}
// 处理Flash外部命令
void CMFCFlashView::FSCommondShockwave(LPCTSTR commond, LPCTSTR args)
{
CString strCmd = _T("add");
CString strX;
CString strY;
double dResult = 0.0f;
CString strResult;
if(strCmd.CompareNoCase(commond) == 0)
{
TRY
{
strX = m_wndFlash.GetVariable(_T("addx"));
}
CATCH_ALL(e)
{
AfxMessageBox(_T("请输入被加数!"));
return;
}
END_CATCH_ALL
if(strX.IsEmpty())
{
AfxMessageBox(_T("请输入被加数!"));
return;
}
TRY
{
strY = m_wndFlash.GetVariable(_T("addy"));
}
CATCH_ALL(e)
{
AfxMessageBox(_T("请输入加数!"));
return;
}
END_CATCH_ALL
if(strY.IsEmpty())
{
AfxMessageBox(_T("请输入加数!"));
return;
}
dResult = atof(strX) + atof(strY);
strResult.Format("%f", dResult);
m_wndFlash.SetVariable(_T("addresult"), strResult);
AfxMessageBox(strX+_T("+")+strY+_T("=")+strResult);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -