c程序设计第十章.pptVIP

  • 6
  • 0
  • 约3.41万字
  • 约 186页
  • 2017-06-03 发布于北京
  • 举报
10.1 Windows消息与命令 10.2 单文档与多文档程序 10.3 对话框与常用组件 10.4 通用对话框与Windows 95控件 表10.9 CTestDialogView类中的成员变量和成员函数 变量类型 变量名称 访问权限 int m_nColor protected CFont* m_ pCurFont protected 函数类型 函数名称 访问权限 Void Redraw(CDC* pDC)n protected CTestDialogView::CTestDialogView( ) { // TODO: add construction code here m_pCurFont=new CFont; m_pCurFont-CreateFont(40, 0, 0, 0, 400, FALSE, FALSE, 0, ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCHFF_SWISS, Aerial); } (6) 编写CTestDialogView( )析构函数: CTestDialogView::~CTestDialogView( ) { delete m_pCurFont; } (7) 编写OnDraw( )函数: void CTestDialogView::OnDraw(CDC* pDC) { CTestDialogDoc* pDoc = GetDocument( ); ASSERT_VALID(pDoc); // TODO: add draw code for native data here Redraw(pDC); } (8) 编写OnTestFontdlg( )函数: void CTestDialogView::OnTestFontdlg( ) { // TODO: Add your command handler code here CFontDialog dlg; int nRet=dlg.DoModal( ); if(nRet==IDOK){ delete m_pCurFont; m_pCurFont=new CFont; m_nCurFont-CreateFont(dlg.GetSize( ), 0, 0, 0, dlg.GetWeight( ), dlg.IsItalic( ), dlg.IsUnderline( ), dlg.IsStrikeOut( ), ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCHFF_SWISS, dlg.GetFaceName( )); m_nColor=dlg.GetColor( ); } CDC* pDC=GetDC( ); Redraw(pDC); } (3) 在文档类的构造函数中将其初始化: (4) 修改OnFileShow( )函数,将对话框中的数据传送到视图中,并更新视图: void CEx06View::OnFileShow( ) CEx06Doc::CEx06Doc( ) { // TODO: add one-time construction code here m_String= ; m_xPosition=0; m_yPosition=0; } { // TODO: Add your command handler code here NewDialog NewDlg; int result=NewDlg.DoModal( ); if(result==IDOK){ CEx06Doc* pDoc=GetDocument( ); ASSERT_VALID(pDoc); pDoc-m_String=NewDlg.m_Text; pDoc-m_xPosition=NewDlg.m_xPos; pDoc-m_yPosition=NewDlg.m_yPos; Invalidate( ); } } (5) 最后要做的工作就是在OnDraw

文档评论(0)

1亿VIP精品文档

相关文档