【VC开源代码栏目提醒】:文章导读:在新的一年中,各位网友都进入紧张的学习或是工作阶段。网学会员整理了VC开源代码-EmbedModuleView.cpp的相关内容供大家参考,祝大家在新的一年里工作和学习顺利!
// EmbedModuleView.cpp : implementation of the CEmbedModuleView class
//
#include "stdafx.h"
#include "EmbedModule.h"
#include "EmbedModuleDoc.h"
#include "EmbedModuleView.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CEmbedModuleView
IMPLEMENT_DYNCREATE(CEmbedModuleView, CHtmlView)
BEGIN_MESSAGE_MAP(CEmbedModuleView, CHtmlView)
//{{AFX_MSG_MAP(CEmbedModuleView)
ON_WM_DESTROY()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CEmbedModuleView construction/destruction
CEmbedModuleView::CEmbedModuleView()
{
// TODO: add construction code here
}
CEmbedModuleView::~CEmbedModuleView()
{
}
BOOL CEmbedModuleView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CHtmlView::PreCreateWindow(cs);
}
/////////////////////////////////////////////////////////////////////////////
// CEmbedModuleView drawing
void CEmbedModuleView::OnDraw(CDC* pDC)
{
CEmbedModuleDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
}
void CEmbedModuleView::OnInitialUpdate()
{
CHtmlView::OnInitialUpdate();
ResToFile (MAKEINTRESOURCE(IDR_SWF1),"swf","Temp.swf");
char exeFullPath[MAX_PATH];
GetModuleFileName(NULL,exeFullPath,MAX_PATH);
m_TempFile.Format("%s",exeFullPath);
exeFullPath[m_TempFile.GetLength()-15]='\0';
m_TempFile.Format("%s",exeFullPath);
m_TempFile+="Temp.swf";
Navigate2(_T(m_TempFile),NULL,NULL);
}
/////////////////////////////////////////////////////////////////////////////
// CEmbedModuleView diagnostics
#ifdef _DEBUG
void CEmbedModuleView::AssertValid() const
{
CHtmlView::AssertValid();
}
void CEmbedModuleView::Dump(CDumpContext& dc) const
{
CHtmlView::Dump(dc);
}
CEmbedModuleDoc* CEmbedModuleView::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CEmbedModuleDoc)));
return (CEmbedModuleDoc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CEmbedModuleView message handlers
int CEmbedModuleView::ResToFile(LPCTSTR lpName, LPCTSTR lpType, LPCTSTR filename)
{
//输入:lpName 为资源名,可用MAKEINTRESOURCE宏将整型变为字符串。
// LpType 为串类型名
// Filename 为释放出的文件名。
//输出:成功1,失败0
HRSRC myres=FindResource (NULL,lpName,lpType);
HGLOBAL gl=LoadResource (NULL,myres);
LPVOID lp=LockResource(gl); //返回指向资源内存的地址的指针。
// CREATE_ALWAYS为不管文件存不存在都产生新文件。
HANDLE fp= CreateFile(filename ,GENERIC_WRITE,0,NULL,CREATE_ALWAYS,0,NULL);
if (!fp)
return false;
DWORD a;
//sizeofResource 得到资源文件的大小
if (!WriteFile (fp,lp,SizeofResource (NULL,myres),&a,NULL))
return false;
CloseHandle (fp);
FreeResource (gl);
return true;
}
void CEmbedModuleView::OnDestroy()
{
CHtmlView::OnDestroy();
DeleteFile(m_TempFile);
}
上一篇:
EmbedModuleDoc.cpp
下一篇:
最新参考文献中的标点符号