Click here to Skip to main content
15,892,674 members
Articles / Desktop Programming / MFC

How to use the res: protocol in Developer Studio

Rate me:
Please Sign up or sign in to vote.
4.65/5 (12 votes)
25 Mar 2000CPOL 86.4K   1.8K   23  
A simple MFC demo application that demonstrates using the res: protocol to use resources in your applications
// ResProjView.cpp : implementation of the CResProjView class
//

#include "stdafx.h"
#include "ResProj.h"

#include "ResProjDoc.h"
#include "ResProjView.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CResProjView

IMPLEMENT_DYNCREATE(CResProjView, CHtmlView)

BEGIN_MESSAGE_MAP(CResProjView, CHtmlView)
	//{{AFX_MSG_MAP(CResProjView)
		// NOTE - the ClassWizard will add and remove mapping macros here.
		//    DO NOT EDIT what you see in these blocks of generated code!
	//}}AFX_MSG_MAP
	// Standard printing commands
	ON_COMMAND(ID_FILE_PRINT, CHtmlView::OnFilePrint)
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CResProjView construction/destruction

CResProjView::CResProjView()
{
	// TODO: add construction code here

}

CResProjView::~CResProjView()
{
}

BOOL CResProjView::PreCreateWindow(CREATESTRUCT& cs)
{
	// TODO: Modify the Window class or styles here by modifying
	//  the CREATESTRUCT cs

	return CHtmlView::PreCreateWindow(cs);
}

/////////////////////////////////////////////////////////////////////////////
// CResProjView drawing

void CResProjView::OnDraw(CDC* pDC)
{
	CResProjDoc* pDoc = GetDocument();
	ASSERT_VALID(pDoc);
	// TODO: add draw code for native data here
}

void CResProjView::OnInitialUpdate()
{
	CHtmlView::OnInitialUpdate();

	// Use The LoadFromResource function
	// In the HTML File to locate resource in
	// your app add the file by name and in binary format
	// of type 2110 ( Magic Number for Microsoft)
	// HTML files are placed automatically under 
	// category of type HTML
	LoadFromResource(IDR_STARTHTML);
}

/////////////////////////////////////////////////////////////////////////////
// CResProjView printing


/////////////////////////////////////////////////////////////////////////////
// CResProjView diagnostics

#ifdef _DEBUG
void CResProjView::AssertValid() const
{
	CHtmlView::AssertValid();
}

void CResProjView::Dump(CDumpContext& dc) const
{
	CHtmlView::Dump(dc);
}

CResProjDoc* CResProjView::GetDocument() // non-debug version is inline
{
	ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CResProjDoc)));
	return (CResProjDoc*)m_pDocument;
}
#endif //_DEBUG

/////////////////////////////////////////////////////////////////////////////
// CResProjView message handlers

void CResProjView::OnTitleChange(LPCTSTR lpszText) 
{
	CDocument *pDoc = GetDocument();
	if(pDoc)
		pDoc->SetTitle(lpszText);
	CHtmlView::OnTitleChange(lpszText);
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Architect
India India
1993 started with Computers

BE(Computer Science) and MS (Software Systems)

Industry Experience: 10 Years

C, C++, VC++(MFC), .NET, C#, MTS, Queuing, ASP.NET, AJAX, Java, J2EE, SunOne, JMS

Banking, Insurance & Pension,Health Care

Comments and Discussions