⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 embedmoduleview.cpp

📁 这是书上的代码
💻 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);
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -