|
// QuickFillDemoDoc.cpp : implementation of the CQuickFillDemoDoc class
//
#include "stdafx.h"
#include "QuickFillDemo.h"
#include "QuickFillDemoDoc.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CQuickFillDemoDoc
IMPLEMENT_DYNCREATE(CQuickFillDemoDoc, CDocument)
BEGIN_MESSAGE_MAP(CQuickFillDemoDoc, CDocument)
//{{AFX_MSG_MAP(CQuickFillDemoDoc)
// 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
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CQuickFillDemoDoc construction/destruction
CQuickFillDemoDoc::CQuickFillDemoDoc()
{
// TODO: add one-time construction code here
}
CQuickFillDemoDoc::~CQuickFillDemoDoc()
{
}
BOOL CQuickFillDemoDoc::OnNewDocument()
{
if (!CDocument::OnNewDocument())
return FALSE;
// TODO: add reinitialization code here
// (SDI documents will reuse this document)
return TRUE;
}
/////////////////////////////////////////////////////////////////////////////
// CQuickFillDemoDoc serialization
void CQuickFillDemoDoc::Serialize(CArchive& ar)
{
if (ar.IsStoring())
{
// TODO: add storing code here
}
else
{
// TODO: add loading code here
}
}
/////////////////////////////////////////////////////////////////////////////
// CQuickFillDemoDoc diagnostics
#ifdef _DEBUG
void CQuickFillDemoDoc::AssertValid() const
{
CDocument::AssertValid();
}
void CQuickFillDemoDoc::Dump(CDumpContext& dc) const
{
CDocument::Dump(dc);
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CQuickFillDemoDoc commands
BOOL CQuickFillDemoDoc::OnOpenDocument(LPCTSTR lpszPathName)
{
if (!CDocument::OnOpenDocument(lpszPathName))
return FALSE;
// TODO: Add your specialized creation code here
m_Bitmap.DeleteObject();
m_BitmapBackup.DeleteObject();
HANDLE hBitmap = ::LoadImage(
NULL, lpszPathName, IMAGE_BITMAP,
0, 0, LR_CREATEDIBSECTION | LR_LOADFROMFILE);
BOOL bResult = m_Bitmap.Attach((HGDIOBJ)hBitmap);
if( bResult )
{
BITMAP bm;
m_Bitmap.GetBitmap(&bm);
CDC dc1, dc2;
dc2.CreateCompatibleDC(NULL);
CBitmap* old2 = dc2.SelectObject(&m_Bitmap);
if( m_BitmapBackup.CreateCompatibleBitmap(&dc2,bm.bmWidth,bm.bmHeight) )
{
dc1.CreateCompatibleDC(&dc2);
CBitmap* old1 = dc1.SelectObject(&m_BitmapBackup);
dc1.BitBlt(0,0,bm.bmWidth,bm.bmHeight,&dc2,0,0,SRCCOPY);
dc1.SelectObject(old1);
dc1.DeleteDC();
}
dc2.SelectObject(old2);
dc2.DeleteDC();
}
return bResult;
}
|
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.
I am a senior software engineer who has been designing and developing software for many years, mostly in C/C++. You might say that I think in code; which is why I am passionate about my first rule of coding: “First do no harm”. So if I get carried away in my explanations, please realize that it is just part of my personality. I enjoy learning new things and, when I have the time, passing that knowledge onto others.