- •Компьютерная графика
- •Лабораторная работа №1 Графические примитивы
- •Задание
- •Последовательность выполнения задания
- •Программный код
- •1.2.1 Среда программирования Microsoft Visual Studio 6. (мастер приложений AppWizard)
- •1.2.2 Среда разработки ms Visual Studio 2010
- •1. Добавим строки, сохраняющие координаты указателя мыши в момент нажатия левой кнопки мыши
- •2. Добавим в метод OnDraw() класса cPainterView строки, которые будут выполнять вывод на экран линий, соединяющих опорные точки.
- •3. Создание нового рисунка. Добавим в метод OnNewDocument() класса cPainterDoc
- •4. Сохранение рисунков в файл. Модифицируем функцию Serialize() класса cPainterDoc в файле PainterDoc.Cpp
- •Лабораторная работа №2 Фракталы
- •Лабораторная работа №3
- •Сплайны. Кривая Безье
- •Задание
- •Последовательность выполнения задания
- •Программный код
- •Лабораторная работа №4
- •Цель работы:
- •Теоретическое введение:
- •Лабораторная работа №5 «Закрашивание. Метод Фонга»
- •Контрольная работа
1.2.1 Среда программирования Microsoft Visual Studio 6. (мастер приложений AppWizard)
Рис.15 Диалоговое окно
Последовательность выполнения действий и результаты (рис.15 – рис.33).
Команда File->New->диалоговое окно New (рис.15)
Работает мастер AppWizard рис.16-рис.23
Рис.16 Выбор типа приложения
Рис.18 Поддержка баз данных
Рис.19 Поддержка составных документов
Рис.20 Возможности программы
Рис.21 Выбор стиля приложения
Рис.22 Классы библиотеки MFC
Рис.23 Информация о приложении
Рис.24 Окно Workspace
Рис.25 Ресурсы проекта
Рис.26 Шаблон диалогового окна About
Рис.27 Диалоговое окно Text Properties
Рис.28 Редактирование текста диалога About
Рис.29 Запуск программы Painter
Добавление функции рисования
Файл PainterDoc.
Рис.30 Добавление программного кода в PainterDoc.h
Файл PainterDoc.cpp
Рис.31 Добавление программного кода в файл CPainterDoc.cpp
Использование мастера классов ClassWizard
Рис.32 Окно MFC ClassWizard
Рис.33 Вставка макрокоманды
В списке классов окна вкладки ClassView дважды щелкнем на имени функции OnLButtonDown() класса CPainterView. Добавим строки, сохраняющие координаты указателя мыши в момент нажатия левой кнопки мыши
void CPainterView::OnLButtonDown(UINT nFlags, CPoint point)
{
//получили указатель на объект-документ
CPainterDoc *pDoc=GetDocument();
//проверим не исчерпали ли ресурс
if(pDoc->m_nIndex==MAXPOINTS)
AfxMessageBox("Слишком много точек");
else
{
//запоминаем точку
pDoc->m_Points[pDoc->m_nIndex++]=point;
//указываем, что окно надо перерисовать
Invalidate();
// указываем, что документ изменен
pDoc->SetModifiedFlag();
}
//даем возможность стандартному обработчику
//тоже поработать над этим сообщением
CView::OnLButtonDown(nFlags, point);
}
Добавим в метод OnDraw() класса CPainterView строки, которые будут выполнять вывод на экран линий, соединяющих опорные точки
void CPainterView::OnDraw(CDC* pDC)
{
CPainterDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
//если имеются опорные точки
if(pDoc->m_nIndex>0)
//поместим перо в первую из них
pDC->MoveTo(pDoc->m_Points[0]);
//пока не кончатся опорные точки будем их соединять
for(int i=1; i<pDoc->m_nIndex; i++)
pDC->LineTo(pDoc->m_Points[i]);
}
4 Сохранение рисунков в файл. Модифицируем функцию Serialize() класса CPainterDoc в файле PainterDoc.cpp
void CPainterDoc::Serialize(CArchive& ar)
{
if (ar.IsStoring())
{
// TODO: add storing code here
//сохраняем количество точек
ar << m_nIndex;
//сохраняем значения координат точек
for(int i=0; i<m_nIndex; i++) ar << m_Points[i];
}
else
{
// TODO: add loading code here
//загружаем количество точек
ar >> m_nIndex;
//загружаем значения координат точек
for(int i=0; i<m_nIndex; i++) ar >> m_Points[i];
}
}
Создание нового рисунка. Добавим в метод OnNewDocument() класса CPainterDoc
BOOL CPainterDoc::OnNewDocument()
{
if (!CDocument::OnNewDocument())
return FALSE;
// TODO: add reinitialization code here
// (SDI documents will reuse this document)
// сбросили счетчик
m_nIndex=0;
// перерисовали
UpdateAllViews(NULL);
return TRUE;
}
Добавим в головной файл PainterDoc.h
// PainterDoc.h : interface of the CPainterDoc class
//
/////////////////////////////////////////////////////////////////////////////
#if !defined(AFX_PAINTERDOC_H__F8B9924B_79CF_11D5_BB4A_20804AC10000__INCLUDED_)
#define AFX_PAINTERDOC_H__F8B9924B_79CF_11D5_BB4A_20804AC10000__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
//определим максимальное количество опорных точек
#define MAXPOINTS 100
class CPainterDoc : public CDocument
{
protected: // create from serialization only
CPainterDoc();
DECLARE_DYNCREATE(CPainterDoc)
// Attributes
public:
//реальное количество точек в массиве
WORD m_nIndex;
//массив координат опорных точек
CPoint m_Points[MAXPOINTS];
// Operations
public:
6. Вывод рисунков на печать и предварительный просмотр.Команда File->Print Preview и Print
Программный код
// MainFrm.cpp : implementation of the CMainFrame class
//
#include "stdafx.h"
#include "Painter.h"
#include "MainFrm.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CMainFrame
IMPLEMENT_DYNCREATE(CMainFrame, CFrameWnd)
BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
//{{AFX_MSG_MAP(CMainFrame)
// NOTE - the ClassWizard will add and remove mapping macros here.
// DO NOT EDIT what you see in these blocks of generated code !
ON_WM_CREATE()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
static UINT indicators[] =
{
ID_SEPARATOR, // status line indicator
ID_INDICATOR_CAPS,
ID_INDICATOR_NUM,
ID_INDICATOR_SCRL,
};
/////////////////////////////////////////////////////////////////////////////
// CMainFrame construction/destruction
CMainFrame::CMainFrame()
{
// TODO: add member initialization code here
}
CMainFrame::~CMainFrame()
{
}
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
return -1;
if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
| CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
!m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
{
TRACE0("Failed to create toolbar\n");
return -1; // fail to create
}
if (!m_wndStatusBar.Create(this) ||
!m_wndStatusBar.SetIndicators(indicators,
sizeof(indicators)/sizeof(UINT)))
{
TRACE0("Failed to create status bar\n");
return -1; // fail to create
}
// TODO: Delete these three lines if you don't want the toolbar to
// be dockable
m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
EnableDocking(CBRS_ALIGN_ANY);
DockControlBar(&m_wndToolBar);
return 0;
}
BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
{
if( !CFrameWnd::PreCreateWindow(cs) )
return FALSE;
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return TRUE;
}
/////////////////////////////////////////////////////////////////////////////
// CMainFrame diagnostics
#ifdef _DEBUG
void CMainFrame::AssertValid() const
{
CFrameWnd::AssertValid();
}
void CMainFrame::Dump(CDumpContext& dc) const
{
CFrameWnd::Dump(dc);
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CMainFrame message handlers
// Painter.cpp : Defines the class behaviors for the application.
//
#include "stdafx.h"
#include "Painter.h"
#include "MainFrm.h"
#include "PainterDoc.h"
#include "PainterView.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CPainterApp
BEGIN_MESSAGE_MAP(CPainterApp, CWinApp)
//{{AFX_MSG_MAP(CPainterApp)
ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
//}}AFX_MSG_MAP
// Standard file based document commands
ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew)
ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen)
// Standard print setup command
ON_COMMAND(ID_FILE_PRINT_SETUP, CWinApp::OnFilePrintSetup)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CPainterApp construction
CPainterApp::CPainterApp()
{
// TODO: add construction code here,
// Place all significant initialization in InitInstance
}
/////////////////////////////////////////////////////////////////////////////
// The one and only CPainterApp object
CPainterApp theApp;
/////////////////////////////////////////////////////////////////////////////
// CPainterApp initialization
BOOL CPainterApp::InitInstance()
{
AfxEnableControlContainer();
// Standard initialization
// If you are not using these features and wish to reduce the size
// of your final executable, you should remove from the following
// the specific initialization routines you do not need.
#ifdef _AFXDLL
Enable3dControls(); // Call this when using MFC in a shared DLL
#else
Enable3dControlsStatic(); // Call this when linking to MFC statically
#endif
// Change the registry key under which our settings are stored.
// TODO: You should modify this string to be something appropriate
// such as the name of your company or organization.
SetRegistryKey(_T("Local AppWizard-Generated Applications"));
LoadStdProfileSettings(); // Load standard INI file options (including MRU)
// Register the application's document templates. Document templates
// serve as the connection between documents, frame windows and views.
CSingleDocTemplate* pDocTemplate;
pDocTemplate = new CSingleDocTemplate(
IDR_MAINFRAME,
RUNTIME_CLASS(CPainterDoc),
RUNTIME_CLASS(CMainFrame), // main SDI frame window
RUNTIME_CLASS(CPainterView));
AddDocTemplate(pDocTemplate);
// Parse command line for standard shell commands, DDE, file open
CCommandLineInfo cmdInfo;
ParseCommandLine(cmdInfo);
// Dispatch commands specified on the command line
if (!ProcessShellCommand(cmdInfo))
return FALSE;
// The one and only window has been initialized, so show and update it.
m_pMainWnd->ShowWindow(SW_SHOW);
m_pMainWnd->UpdateWindow();
return TRUE;
}
/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About
class CAboutDlg : public CDialog
{
public:
CAboutDlg();
// Dialog Data
//{{AFX_DATA(CAboutDlg)
enum { IDD = IDD_ABOUTBOX };
//}}AFX_DATA
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CAboutDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
//{{AFX_MSG(CAboutDlg)
// No message handlers
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
//{{AFX_DATA_INIT(CAboutDlg)
//}}AFX_DATA_INIT
}
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CAboutDlg)
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
//{{AFX_MSG_MAP(CAboutDlg)
// No message handlers
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
// App command to run the dialog
void CPainterApp::OnAppAbout()
{
CAboutDlg aboutDlg;
aboutDlg.DoModal();
}
/////////////////////////////////////////////////////////////////////////////
// CPainterApp message handlers
// PainterDoc.cpp : implementation of the CPainterDoc class
//
#include "stdafx.h"
#include "Painter.h"
#include "PainterDoc.h"
#include "PainterView.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CPainterDoc
IMPLEMENT_DYNCREATE(CPainterDoc, CDocument)
BEGIN_MESSAGE_MAP(CPainterDoc, CDocument)
//{{AFX_MSG_MAP(CPainterDoc)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CPainterDoc construction/destruction
CPainterDoc::CPainterDoc()
{
// сначала в массиве нет точек
m_nIndex=0;
}
CPainterDoc::~CPainterDoc()
{
}
BOOL CPainterDoc::OnNewDocument()
{
if (!CDocument::OnNewDocument())
return FALSE;
// TODO: add reinitialization code here
// (SDI documents will reuse this document)
// сбросили счетчик
m_nIndex=0;
// перерисовали
UpdateAllViews(NULL);
return TRUE;
}
/////////////////////////////////////////////////////////////////////////////
// CPainterDoc serialization
void CPainterDoc::Serialize(CArchive& ar)
{
if (ar.IsStoring())
{
// TODO: add storing code here
//сохраняем количество точек
ar << m_nIndex;
//сохраняем значения координат точек
for(int i=0; i<m_nIndex; i++) ar << m_Points[i];
}
else
{
// TODO: add loading code here
//загружаем количество точек
ar >> m_nIndex;
//загружаем значения координат точек
for(int i=0; i<m_nIndex; i++) ar >> m_Points[i];
}
}
/////////////////////////////////////////////////////////////////////////////
// CPainterDoc diagnostics
#ifdef _DEBUG
void CPainterDoc::AssertValid() const
{
CDocument::AssertValid();
}
void CPainterDoc::Dump(CDumpContext& dc) const
{
CDocument::Dump(dc);
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CPainterDoc commands
// PainterView.cpp : implementation of the CPainterView class
//
#include "stdafx.h"
#include "Painter.h"
#include "PainterDoc.h"
#include "PainterView.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CPainterView
IMPLEMENT_DYNCREATE(CPainterView, CView)
BEGIN_MESSAGE_MAP(CPainterView, CView)
//{{AFX_MSG_MAP(CPainterView)
ON_WM_LBUTTONDOWN()
//}}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()
/////////////////////////////////////////////////////////////////////////////
// CPainterView construction/destruction
CPainterView::CPainterView()
{
// TODO: add construction code here
}
CPainterView::~CPainterView()
{
}
BOOL CPainterView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CView::PreCreateWindow(cs);
}
/////////////////////////////////////////////////////////////////////////////
// CPainterView drawing
void CPainterView::OnDraw(CDC* pDC)
{
CPainterDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
//если имеются опорные точки
if(pDoc->m_nIndex>0)
//поместим перо в первую из них
pDC->MoveTo(pDoc->m_Points[0]);
//пока не кончатся опорные точки будем их соединять
for(int i=1; i<pDoc->m_nIndex; i++)
pDC->LineTo(pDoc->m_Points[i]);
}
/////////////////////////////////////////////////////////////////////////////
// CPainterView printing
BOOL CPainterView::OnPreparePrinting(CPrintInfo* pInfo)
{
// default preparation
return DoPreparePrinting(pInfo);
}
void CPainterView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add extra initialization before printing
}
void CPainterView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add cleanup after printing
}
/////////////////////////////////////////////////////////////////////////////
// CPainterView diagnostics
#ifdef _DEBUG
void CPainterView::AssertValid() const
{
CView::AssertValid();
}
void CPainterView::Dump(CDumpContext& dc) const
{
CView::Dump(dc);
}
CPainterDoc* CPainterView::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CPainterDoc)));
return (CPainterDoc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CPainterView message handlers
void CPainterView::OnLButtonDown(UINT nFlags, CPoint point)
{
//получили указатель на объект-документ
CPainterDoc *pDoc=GetDocument();
//проверим не исчерпали ли ресурс
if(pDoc->m_nIndex==MAXPOINTS)
AfxMessageBox("Слишком много точек");
else
{
//запоминаем точку
pDoc->m_Points[pDoc->m_nIndex++]=point;
//указываем, что окно надо перерисовать
Invalidate();
// указываем, что документ изменен
pDoc->SetModifiedFlag();
}
//даем возможность стандартному обработчику
//тоже поработать над этим сообщением
CView::OnLButtonDown(nFlags, point);
}
// stdafx.cpp : source file that includes just the standard includes
// Painter.pch will be the pre-compiled header
// stdafx.obj will contain the pre-compiled type information
#include "stdafx.h"
// MainFrm.h : interface of the CMainFrame class
//
/////////////////////////////////////////////////////////////////////////////
#if !defined(AFX_MAINFRM_H__F8B99249_79CF_11D5_BB4A_20804AC10000__INCLUDED_)
#define AFX_MAINFRM_H__F8B99249_79CF_11D5_BB4A_20804AC10000__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
class CMainFrame : public CFrameWnd
{
protected: // create from serialization only
CMainFrame();
DECLARE_DYNCREATE(CMainFrame)
// Attributes
public:
// Operations
public:
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CMainFrame)
virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
//}}AFX_VIRTUAL
// Implementation
public:
virtual ~CMainFrame();
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext& dc) const;
#endif
protected: // control bar embedded members
CStatusBar m_wndStatusBar;
CToolBar m_wndToolBar;
// Generated message map functions
protected:
//{{AFX_MSG(CMainFrame)
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
// NOTE - the ClassWizard will add and remove member functions here.
// DO NOT EDIT what you see in these blocks of generated code!
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_MAINFRM_H__F8B99249_79CF_11D5_BB4A_20804AC10000__INCLUDED_)
// Painter.h : main header file for the PAINTER application
//
#if !defined(AFX_PAINTER_H__F8B99245_79CF_11D5_BB4A_20804AC10000__INCLUDED_)
#define AFX_PAINTER_H__F8B99245_79CF_11D5_BB4A_20804AC10000__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#ifndef __AFXWIN_H__
#error include 'stdafx.h' before including this file for PCH
#endif
#include "resource.h" // main symbols
/////////////////////////////////////////////////////////////////////////////
// CPainterApp:
// See Painter.cpp for the implementation of this class
//
class CPainterApp : public CWinApp
{
public:
CPainterApp();
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CPainterApp)
public:
virtual BOOL InitInstance();
//}}AFX_VIRTUAL
// Implementation
//{{AFX_MSG(CPainterApp)
afx_msg void OnAppAbout();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_PAINTER_H__F8B99245_79CF_11D5_BB4A_20804AC10000__INCLUDED_)
// PainterDoc.h : interface of the CPainterDoc class
//
/////////////////////////////////////////////////////////////////////////////
#if !defined(AFX_PAINTERDOC_H__F8B9924B_79CF_11D5_BB4A_20804AC10000__INCLUDED_)
#define AFX_PAINTERDOC_H__F8B9924B_79CF_11D5_BB4A_20804AC10000__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
//определим максимальное количество опорных точек
#define MAXPOINTS 100
class CPainterDoc : public CDocument
{
protected: // create from serialization only
CPainterDoc();
DECLARE_DYNCREATE(CPainterDoc)
// Attributes
public:
//реальное количество точек в массиве
WORD m_nIndex;
//массив координат опорных точек
CPoint m_Points[MAXPOINTS];
// Operations
public:
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CPainterDoc)
public:
virtual BOOL OnNewDocument();
virtual void Serialize(CArchive& ar);
//}}AFX_VIRTUAL
// Implementation
public:
virtual ~CPainterDoc();
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext& dc) const;
#endif
protected:
// Generated message map functions
protected:
//{{AFX_MSG(CPainterDoc)
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_PAINTERDOC_H__F8B9924B_79CF_11D5_BB4A_20804AC10000__INCLUDED_)
// PainterView.h : interface of the CPainterView class
//
/////////////////////////////////////////////////////////////////////////////
#if !defined(AFX_PAINTERVIEW_H__F8B9924D_79CF_11D5_BB4A_20804AC10000__INCLUDED_)
#define AFX_PAINTERVIEW_H__F8B9924D_79CF_11D5_BB4A_20804AC10000__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
class CPainterView : public CView
{
protected: // create from serialization only
CPainterView();
DECLARE_DYNCREATE(CPainterView)
// Attributes
public:
CPainterDoc* GetDocument();
// Operations
public:
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CPainterView)
public:
virtual void OnDraw(CDC* pDC); // overridden to draw this view
virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
protected:
virtual BOOL OnPreparePrinting(CPrintInfo* pInfo);
virtual void OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo);
virtual void OnEndPrinting(CDC* pDC, CPrintInfo* pInfo);
//}}AFX_VIRTUAL
// Implementation
public:
virtual ~CPainterView();
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext& dc) const;
#endif
protected:
// Generated message map functions
protected:
//{{AFX_MSG(CPainterView)
afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
#ifndef _DEBUG // debug version in PainterView.cpp
inline CPainterDoc* CPainterView::GetDocument()
{ return (CPainterDoc*)m_pDocument; }
#endif
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_PAINTERVIEW_H__F8B9924D_79CF_11D5_BB4A_20804AC10000__INCLUDED_)
//Resource.h
//{{NO_DEPENDENCIES}}
// Microsoft Developer Studio generated include file.
// Used by Painter.rc
//
#define IDD_ABOUTBOX 100
#define IDR_MAINFRAME 128
#define IDR_PAINTETYPE 129
#define ID_TEXT 32771
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_3D_CONTROLS 1
#define _APS_NEXT_RESOURCE_VALUE 130
#define _APS_NEXT_COMMAND_VALUE 32772
#define _APS_NEXT_CONTROL_VALUE 1000
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif
//Resource.h
//{{NO_DEPENDENCIES}}
// Microsoft Developer Studio generated include file.
// Used by Painter.rc
//
#define IDD_ABOUTBOX 100
#define IDR_MAINFRAME 128
#define IDR_PAINTETYPE 129
#define ID_TEXT 32771
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_3D_CONTROLS 1
#define _APS_NEXT_RESOURCE_VALUE 130
#define _APS_NEXT_COMMAND_VALUE 32772
#define _APS_NEXT_CONTROL_VALUE 1000
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif
Рис. 34 Результат работы программы
