📄 dlgandctldemo.cpp
字号:
// DlgAndCtlDemo.cpp : implementation file
//
#include "stdafx.h"
#include "DemonstrateCTL.h"
#include "DlgAndCtlDemo.h"
/*-------------------------------------Sammy2006.11.1------------------------------
加上下面#include "DemonstrateCTLView.h "这个语句后编译器会出以下三个错:
1.error C2143: syntax error : missing ';' before '*'
2.'CDemonstrateCTLDoc' : missing storage-class or type specifiers
3.'GetDocument' : missing storage-class or type specifiers
出错原因:在CDemonstrateCTLView类的声明中用到了CDemonstrateCTLDoc类,而在
"DemonstrateCTLView.h "中没有包含CDemonstrateCTLDoc类的声明(即没有在
DemonstrateCTLView.h 文件中用#include "DemonstrateCTLDoc.h"语句把
CDemonstrateCTLDoc类的声明包含进来),当在此文件中用
#include "DemonstrateCTLView.h "语句时,编译器无法找到CDemonstrateCTLDoc类
所以出错。
解决方法:
方法一:在"DemonstrateCTLView.h文件中CDemonstrateCTLView类声明之前加入
class CDemonstrateCTLDoc;语句,从而使编译器在编译本文件时能找到
CDemonstrateCTLDoc类。(本程序采用这种方案)
方法二:在"DemonstrateCTLView.h文件中CDemonstrateCTLView类声明之前加入
#include "DemonstrateCTLDoc.h "语句,从而使编译器在编译本文件时能找到
CDemonstrateCTLDoc类。
方法三:在本类中使用按顺序加入以下两个include语句。
#include "DemonstrateCTLDoc.h "
#include "DemonstrateCTLView.h "
-----------------------------------------------------------------------------------*/
//#include "DemonstrateCTLDoc.h "
#include "DemonstrateCTLView.h "
//-------------------------Sammy:------------------------------------------
#include "MainFrm.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CDlgAndCtlDemo dialog
CDlgAndCtlDemo::CDlgAndCtlDemo(CWnd* pParent /*=NULL*/)
: CDialog(CDlgAndCtlDemo::IDD, pParent)
{
//{{AFX_DATA_INIT(CDlgAndCtlDemo)
m_Color = 0;
m_Content1 = FALSE;
m_Content2 = FALSE;
m_Content3 = FALSE;
m_Align = -1;
m_nPlantOrAnimal = -1;
m_BkMode = -1;
//}}AFX_DATA_INIT
}
void CDlgAndCtlDemo::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CDlgAndCtlDemo)
DDX_Control(pDX, IDC_COMBOANIMALPLANT, m_ComboAniOrPlant);
DDX_Control(pDX, IDC_COLORSPIN, m_ColorSpin);
DDX_Control(pDX, IDC_BKMODE, m_BkModeCtrl);
DDX_Text(pDX, IDC_COLOR, m_Color);
DDX_Check(pDX, IDC_CONTENT1, m_Content1);
DDX_Check(pDX, IDC_CONTENT2, m_Content2);
DDX_Check(pDX, IDC_CONTENT3, m_Content3);
DDX_Radio(pDX, IDC_LEFT, m_Align);
DDX_Radio(pDX, IDC_ANIMAL, m_nPlantOrAnimal);
DDX_CBIndex(pDX, IDC_BKMODE, m_BkMode);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CDlgAndCtlDemo, CDialog)
//{{AFX_MSG_MAP(CDlgAndCtlDemo)
ON_BN_CLICKED(IDC_APPLY, OnApply)
ON_CBN_DROPDOWN(IDC_COMBOANIMALPLANT, OnDropdownComboanimalplant)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CDlgAndCtlDemo message handlers
void CDlgAndCtlDemo::OnApply()
{
//更新数据
UpdateData(TRUE);
//获得视图对象指针
CMainFrame *pFrame=(CMainFrame *)AfxGetApp()->m_pMainWnd;
CDemonstrateCTLView *pActiveView=(CDemonstrateCTLView *)pFrame->GetActiveView();
//把对话框对象中的数据保存到视图对象中去
pActiveView->m_bIsSelHello=m_Content1;
pActiveView->m_bIsSelWorld=m_Content2;
pActiveView->m_bIsSelExcalmatoryMark=m_Content3;
pActiveView->m_lTextColor=m_Color;
if(m_BkMode==0) pActiveView->m_nBkMode=OPAQUE;
else if(m_BkMode==1) pActiveView->m_nBkMode=TRANSPARENT;
if(m_Align==0) pActiveView->m_nTextAlign=TA_LEFT;
else if(m_Align==1) pActiveView->m_nTextAlign=TA_CENTER;
else if (m_Align==2) pActiveView->m_nTextAlign=TA_RIGHT;
//重新绘制视图
pActiveView->Invalidate(TRUE);
}
BOOL CDlgAndCtlDemo::OnInitDialog()
{
CDialog::OnInitDialog();
m_ColorSpin.SetRange(0,9999);
//CSpinButtonCtrl* pSpin = (CSpinButtonCtrl*)GetDlgItem(IDC_COLORSPIN)
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CDlgAndCtlDemo::OnDropdownComboanimalplant()
{
UpdateData();
UpdateData(TRUE);
m_ComboAniOrPlant.ResetContent();
switch (m_nPlantOrAnimal)
{
case 0://动物
{
m_ComboAniOrPlant.AddString("藏羚羊");
m_ComboAniOrPlant.AddString("恐龙");
break;
}
case 1://植物
{
m_ComboAniOrPlant.AddString("君子兰");
m_ComboAniOrPlant.AddString("玫瑰");
break;
}
default:
break;
}//switch
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -