Vous êtes sur la page 1sur 7

PROGRAM

// di.cpp : implementation file

#include "stdafx.h"
#include "modles.h"
#include "di.h"

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

// Cdi dialog

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


: CDialog(Cdi::IDD, pParent)
{
//{{AFX_DATA_INIT(Cdi)
m_edit1 = _T("");
//}}AFX_DATA_INIT
}

void Cdi::DoDataExchange(CDataExchange* pDX)


{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(Cdi)
DDX_Text(pDX, IDC_EDIT1, m_edit1);
//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(Cdi, CDialog)
//{{AFX_MSG_MAP(Cdi)
ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()

// Cdi message handlers

void Cdi::OnButton1()
{
UpdateData(true);
CDC* pDC=GetDC();
pDC->TextOut(10,10,m_edit1);
ReleaseDC(pDC);
}

// modlesView.cpp : implementation of the CModlesView class

#include "stdafx.h"
#include "modles.h"
#include "di.h"
#include "modlesDoc.h"
#include "modlesView.h"

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

// CModlesView

IMPLEMENT_DYNCREATE(CModlesView, CView)
BEGIN_MESSAGE_MAP(CModlesView, CView)
//{{AFX_MSG_MAP(CModlesView)
ON_WM_LBUTTONDOWN()
ON_WM_RBUTTONDOWN()
//}}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()

// CModlesView construction/destruction

CModlesView::CModlesView()
{
m_pdlg=new Cdi(this);
}

CModlesView::~CModlesView()
{
delete m_pdlg;
}

BOOL CModlesView::PreCreateWindow(CREATESTRUCT& cs)


{
return CView::PreCreateWindow(cs);
}

// CModlesView drawing

void CModlesView::OnDraw(CDC* pDC)


{
CModlesDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
}

// CModlesView printing

BOOL CModlesView::OnPreparePrinting(CPrintInfo* pInfo)


{
return DoPreparePrinting(pInfo);
}

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


{}

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


{}

// CModlesView diagnostics

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

void CModlesView::Dump(CDumpContext& dc) const


{
CView::Dump(dc);
}

CModlesDoc* CModlesView::GetDocument() // non-debug version is inline


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

// CModlesView message handlers

void CModlesView::OnLButtonDown(UINT nFlags, CPoint point)


{
m_pdlg->Create(IDD_DIALOG1,this);
m_pdlg->ShowWindow(SW_SHOW);
CView::OnLButtonDown(nFlags, point);
}

void CModlesView::OnRButtonDown(UINT nFlags, CPoint point)


{
m_pdlg->DestroyWindow();
CView::OnRButtonDown(nFlags, point);
}

// modlesView.h : interface of the CModlesView class

#if !
defined(AFX_MODLESVIEW_H__E29AFA05_3905_4883_A5F4_3840B06
ACA5E__INCLUDED_)
#define
AFX_MODLESVIEW_H__E29AFA05_3905_4883_A5F4_3840B06ACA5E_
_INCLUDED_
#include "di.h"
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

class CModlesView : public CView


{
protected:
CModlesView();
DECLARE_DYNCREATE(CModlesView)

// Attributes
public:
CModlesDoc* GetDocument();
Cdi* m_pdlg;
// Operations
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 ~CModlesView();
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext& dc) const;
#endif

// Generated message map functions


protected:
//{{AFX_MSG(CModlesView)
afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
afx_msg void OnRButtonDown(UINT nFlags, CPoint point);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};

#ifndef _DEBUG // debug version in modlesView.cpp


inline CModlesDoc* CModlesView::GetDocument()
{ return (CModlesDoc*)m_pDocument; }

#endif // !
defined(AFX_MODLESVIEW_H__E29AFA05_3905_4883_A5F4_3840B06
ACA5E__INCLUDED_)
OUTPUT

Vous aimerez peut-être aussi