posts - 13,  comments - 0,  trackbacks - 0
#pragma once
#define IDC_BUTTON 1001
class CDialog_ControlView : public CView
{
protected: // 仅从序列化创建
 CDialog_ControlView();
 DECLARE_DYNCREATE(CDialog_ControlView)
// 属性
public:
 CDialog_ControlDoc* GetDocument() const;
// 操作
public:
 CButton m_button;
// 重写
public:
 virtual void OnDraw(CDC* pDC);  // 重写以绘制该视图
 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);
// 实现
public:
 virtual ~CDialog_ControlView();
#ifdef _DEBUG
 virtual void AssertValid() const;
 virtual void Dump(CDumpContext& dc) const;
#endif
protected:
// 生成的消息映射函数
protected:
 //{{AFX_MSG(CDialog_ControlView)
 afx_msg void OnButton();
 //}}AFX_MSG
 DECLARE_MESSAGE_MAP()
};
#ifndef _DEBUG  // Dialog_ControlView.cpp 中的调试版本
inline CDialog_ControlDoc* CDialog_ControlView::GetDocument() const
   { return reinterpret_cast<CDialog_ControlDoc*>(m_pDocument); }
#endif
 
————————————————————————————————————————————————————————————————————
 
// Dialog_ControlView.cpp : CDialog_ControlView 类的实现
//
#include "stdafx.h"
#include "Dialog_Control.h"
#include "Dialog_ControlDoc.h"
#include "Dialog_ControlView.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#endif

// CDialog_ControlView
IMPLEMENT_DYNCREATE(CDialog_ControlView, CView)
BEGIN_MESSAGE_MAP(CDialog_ControlView, CView)
 //{{AFX_MSG_MAP(CDialog_ControlView)
 ON_BN_CLICKED(IDC_BUTTON, OnButton)
 //}}AFX_MSG_MAP

 // 标准打印命令
 ON_COMMAND(ID_FILE_PRINT, &CView::OnFilePrint)
 ON_COMMAND(ID_FILE_PRINT_DIRECT, &CView::OnFilePrint)
 ON_COMMAND(ID_FILE_PRINT_PREVIEW, &CView::OnFilePrintPreview)
 ON_WM_SIZE()
END_MESSAGE_MAP()
// CDialog_ControlView 构造/析构
CDialog_ControlView::CDialog_ControlView()
{
 // TODO: 在此处添加构造代码
}
CDialog_ControlView::~CDialog_ControlView()
{
}
BOOL CDialog_ControlView::PreCreateWindow(CREATESTRUCT& cs)
{
 // TODO: 在此处通过修改
 //  CREATESTRUCT cs 来修改窗口类或样式
 return CView::PreCreateWindow(cs);
}
// CDialog_ControlView 绘制
void CDialog_ControlView::OnDraw(CDC* /*pDC*/)
{
 CDialog_ControlDoc* pDoc = GetDocument();
 ASSERT_VALID(pDoc);
 if (!pDoc)
  return;
 // TODO: 在此处为本机数据添加绘制代码
  //创建按钮
  m_button.Create(
  //按钮标题
  "i am a dynimic button",
  //按钮风格
  WS_CHILD|WS_VISIBLE|WS_BORDER,
  //按钮大小
  CRect(300,40,500,80),
  //按钮父指针
  this,
  //该按钮对应的ID号
  IDC_BUTTON);
}

// CDialog_ControlView 打印
BOOL CDialog_ControlView::OnPreparePrinting(CPrintInfo* pInfo)
{
 // 默认准备
 return DoPreparePrinting(pInfo);
}
void CDialog_ControlView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
 // TODO: 添加额外的打印前进行的初始化过程
}
void CDialog_ControlView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
 // TODO: 添加打印后进行的清理过程
}

// CDialog_ControlView 诊断
#ifdef _DEBUG
void CDialog_ControlView::AssertValid() const
{
 CView::AssertValid();
}
void CDialog_ControlView::Dump(CDumpContext& dc) const
{
 CView::Dump(dc);
}
CDialog_ControlDoc* CDialog_ControlView::GetDocument() const // 非调试版本是内联的
{
 ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CDialog_ControlDoc)));
 return (CDialog_ControlDoc*)m_pDocument;
}
#endif //_DEBUG

// CDialog_ControlView 消息处理程序
void CDialog_ControlView::OnButton()
{
 MessageBox("okk");
}

posted on 2010-12-26 22:24 xiwrong 阅读(209) 评论(0)  编辑 收藏 引用

只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理


<2010年12月>
2829301234
567891011
12131415161718
19202122232425
2627282930311
2345678

常用链接

留言簿

随笔档案

搜索

  •  

最新随笔

最新评论

评论排行榜