Program / DLG.H

Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 10

PROGRAM

/* Dlg.h */
#if !
defined(AFX_DLG_H__D203A2A4_25FC_4F93_83B1_A5979DCD502A__INC
LUDED_)
#define
AFX_DLG_H__D203A2A4_25FC_4F93_83B1_A5979DCD502A__INCLUDED
_

#if _MSC_VER > 1000


#pragma once
#endif // _MSC_VER > 1000
// Dlg.h : header file
//

// CDlg dialog

class CDlg : public CDialog


{
// Construction
public:
CDlg(CWnd* pParent = NULL); // standard constructor
CBitmapButton m_copy;
CBitmapButton m_cut;
CBitmapButton m_paste;
int choice;

// Dialog Data
//{{AFX_DATA(CDlg)
enum { IDD = IDD_DIALOG1 };
// NOTE: the ClassWizard will add data members here
//}}AFX_DATA
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV
support
//}}AFX_VIRTUAL

// Implementation
protected:

// Generated message map functions


//{{AFX_MSG(CDlg)
virtual BOOL OnInitDialog();
afx_msg void OnButton1();
afx_msg void OnButton2();
afx_msg void OnButton3();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};

//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the
previous line.

#endif // !
defined(AFX_DLG_H__D203A2A4_25FC_4F93_83B1_A5979DCD502A__INC
LUDED_)

// Dlg.cpp : implementation file

#include "stdafx.h"
#include "Bitmap.h"
#include "Dlg.h"

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

// CDlg dialog

CDlg::CDlg(CWnd* pParent /*=NULL*/)


: CDialog(CDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CDlg)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
}

void CDlg::DoDataExchange(CDataExchange* pDX)


{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CDlg)
// NOTE: the ClassWizard will add DDX and DDV calls here
//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CDlg, CDialog)
//{{AFX_MSG_MAP(CDlg)
ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
ON_BN_CLICKED(IDC_BUTTON2, OnButton2)
ON_BN_CLICKED(IDC_BUTTON3, OnButton3)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
// CDlg message handlers

BOOL CDlg::OnInitDialog()
{
CDialog::OnInitDialog();
m_copy.AutoLoad(IDC_BUTTON1,this);
m_cut.AutoLoad(IDC_BUTTON2,this);
m_paste.AutoLoad(IDC_BUTTON3,this);

return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}

void CDlg::OnButton1()
{
choice=1;
Invalidate();
}

void CDlg::OnButton2()
{
choice=2;
Invalidate();
}

void CDlg::OnButton3()
{
choice=3;
Invalidate();

// BitmapView.cpp : implementation of the CBitmapView class

#include "stdafx.h"
#include "Bitmap.h"
#include "Dlg.h"

#include "BitmapDoc.h"
#include "BitmapView.h"

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

// CBitmapView

IMPLEMENT_DYNCREATE(CBitmapView, CView)

BEGIN_MESSAGE_MAP(CBitmapView, CView)
//{{AFX_MSG_MAP(CBitmapView)
//}}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()

BOOL CBitmapView::PreCreateWindow(CREATESTRUCT& cs)


{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs

return CView::PreCreateWindow(cs);
}

// CBitmapView drawing

void CBitmapView::OnDraw(CDC* pDC)


{
CBitmapDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here

CDlg d;
d.DoModal();
if(d.choice ==1)
{
CBitmap bmp;
if(bmp.LoadBitmap(&"COPYD"))
{
CDC dcMemory;
dcMemory.CreateCompatibleDC(pDC);
dcMemory.SelectObject(&bmp);
pDC->BitBlt(100,100,200,200,&dcMemory,0,0,SRCCOPY);
}
}

if(d.choice ==2)
{
CBitmap bmp;
if(bmp.LoadBitmap(&"CUTD"))
{
CDC dcMemory;
dcMemory.CreateCompatibleDC(pDC);
dcMemory.SelectObject(&bmp);
pDC->BitBlt(100,100,200,200,&dcMemory,0,0,SRCCOPY);
}
}

if(d.choice ==3)
{
CBitmap bmp;
if(bmp.LoadBitmap(&"PASTED"))
{
CDC dcMemory;
dcMemory.CreateCompatibleDC(pDC);
dcMemory.SelectObject(&bmp);
pDC->BitBlt(100,100,200,200,&dcMemory,0,0,SRCCOPY);
}
}

// CBitmapView printing

BOOL CBitmapView::OnPreparePrinting(CPrintInfo* pInfo)


{
// default preparation
return DoPreparePrinting(pInfo);
}

void CBitmapView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)


{
// TODO: add extra initialization before printing
}

void CBitmapView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)


{
// TODO: add cleanup after printing
}

// CBitmapView diagnostics

#ifdef _DEBUG
void CBitmapView::AssertValid() const
{
CView::AssertValid();
}

void CBitmapView::Dump(CDumpContext& dc) const


{
CView::Dump(dc);
}

CBitmapDoc* CBitmapView::GetDocument() // non-debug version is inline


{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CBitmapDoc)));
return (CBitmapDoc*)m_pDocument;
}
#endif //_DEBUG

/////////////////////////////////////////////////////////////////////////////
// CBitmapView message handlers

BITMAPS

COPYD COPYU

CUTD
CUTU
PASTED
PASTEU

OUTPUT

You might also like