📄 classinfodlg.cpp
字号:
// ClassInfoDlg.cpp : implementation file
//
#include "stdafx.h"
#include "RSIP.h"
#include "ClassInfoDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CClassInfoDlg dialog
CClassInfoDlg::CClassInfoDlg(CWnd* pParent /*=NULL*/)
: CDialog(CClassInfoDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CClassInfoDlg)
//}}AFX_DATA_INIT
m_clrColor = RGB(0,0,0);
m_bChange = FALSE;
m_CurSelIndex = 0;
pView = (CRSIPView *)pParent;
}
CClassInfoDlg::~CClassInfoDlg()
{
//为了保存修改的结果,不能释放内存。
//内存将由文档来释放。
/*
int num = thematicInfoArray.GetSize();
LPRSTHEMATICINFO lp = NULL;
for(int i=0; i<num; i++)
{
lp = thematicInfoArray.GetAt(i);
ASSERT(lp != NULL);
delete lp;
lp = NULL;
}
*/
ClassInfoArray.RemoveAll();
}
void CClassInfoDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CClassInfoDlg)
DDX_Control(pDX, IDC_ID_COMBO, m_IDList);
DDX_Control(pDX, IDC_CLASSLIST_COMBO, m_ClassList);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CClassInfoDlg, CDialog)
//{{AFX_MSG_MAP(CClassInfoDlg)
ON_EN_CHANGE(IDC_RED, OnChangeEdit)
ON_BN_CLICKED(IDC_SELCOLOR, OnSelcolor)
ON_WM_PAINT()
ON_CBN_SELCHANGE(IDC_CLASSLIST_COMBO, OnSelchangeClasslistCombo)
ON_CBN_SELCHANGE(IDC_ID_COMBO, OnSelchangeIdCombo)
ON_BN_CLICKED(IDC_APPLY, OnApply)
ON_EN_CHANGE(IDC_GREEN, OnChangeEdit)
ON_EN_CHANGE(IDC_BLUE, OnChangeEdit)
ON_CBN_EDITCHANGE(IDC_CLASSLIST_COMBO, OnEditchangeClasslistCombo)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CClassInfoDlg message handlers
BOOL CClassInfoDlg::OnInitDialog()
{
CDialog::OnInitDialog();
CString pszTemp;
int nTemp;
char pChar[10];
for(int i=0; i<ClassInfoArray.GetSize(); i++)
{
pszTemp = ClassInfoArray.GetAt(i)->m_szClassName;
nTemp = ClassInfoArray.GetAt(i)->m_nValue;
itoa(nTemp,pChar,10);
m_ClassList.AddString(pszTemp);
m_IDList.AddString((LPCTSTR)pChar);
}
m_ClassList.SetCurSel(m_CurSelIndex);
m_IDList.SetCurSel(m_CurSelIndex);
m_clrColor = ClassInfoArray.GetAt(m_CurSelIndex)->m_clrColor;
m_bChange = TRUE;
SetDlgItemInt(IDC_RED,GetRValue(m_clrColor));
SetDlgItemInt(IDC_GREEN,GetGValue(m_clrColor));
SetDlgItemInt(IDC_BLUE,GetBValue(m_clrColor));
m_bChange = FALSE;
RECT Rect;
SetRect(&Rect,137,89,20,20);
MapDialogRect(&Rect);
InvalidateRect(&Rect);
return TRUE;
}
/////////////////////////////////////////////////////////////////////////////
// CInputClassInfoDialog message handlers
void CClassInfoDlg::OnChangeEdit()
{
if(m_bChange == TRUE)
return;
int nRed;
int nGreen;
int nBlue;
nRed = GetDlgItemInt(IDC_RED);
if(nRed < 0)
nRed = 0;
if(nRed > 255)
nRed = 255;
nGreen = GetDlgItemInt(IDC_GREEN);
if(nGreen < 0)
nGreen = 0;
if(nGreen > 255)
nGreen = 255;
nBlue = GetDlgItemInt(IDC_BLUE);
if(nBlue < 0)
nBlue = 0;
if(nBlue > 255)
nBlue = 255;
m_clrColor = RGB(nRed,nGreen,nBlue);
ClassInfoArray.GetAt(m_CurSelIndex)->m_clrColor = m_clrColor;
RECT Rect;
SetRect(&Rect,137,89,20,20);
MapDialogRect(&Rect);
InvalidateRect(&Rect);
}
void CClassInfoDlg::OnSelcolor()
{
CColorDialog ColorDlg(m_clrColor,CC_RGBINIT,this);
if(ColorDlg.DoModal() == IDOK)
{
m_clrColor = ColorDlg.GetColor();
m_bChange = TRUE;
SetDlgItemInt(IDC_RED,GetRValue(m_clrColor));
SetDlgItemInt(IDC_GREEN,GetGValue(m_clrColor));
SetDlgItemInt(IDC_BLUE,GetBValue(m_clrColor));
m_bChange = FALSE;
ClassInfoArray.GetAt(m_CurSelIndex)->m_clrColor = m_clrColor;
RECT Rect;
SetRect(&Rect,137,89,20,20);
MapDialogRect(&Rect);
InvalidateRect(&Rect);
}
}
void CClassInfoDlg::OnPaint()
{
CPaintDC dc(this); // device context for painting
RECT Rect;
SetRect(&Rect,137,89,20,20);
MapDialogRect(&Rect);
CBrush Brush(m_clrColor);
CBrush *pOldBrush = dc.SelectObject(&Brush);
dc.Rectangle(&Rect);
dc.SelectObject(pOldBrush);
}
void CClassInfoDlg::OnSelchangeClasslistCombo()
{
int nIndex = m_ClassList.GetCurSel();
if(m_CurSelIndex == nIndex)
return;
else
m_CurSelIndex = nIndex;
m_IDList.SetCurSel(m_CurSelIndex);
m_clrColor = ClassInfoArray.GetAt(m_CurSelIndex)->m_clrColor;
m_bChange = TRUE;
SetDlgItemInt(IDC_RED,GetRValue(m_clrColor));
SetDlgItemInt(IDC_GREEN,GetGValue(m_clrColor));
SetDlgItemInt(IDC_BLUE,GetBValue(m_clrColor));
m_bChange = FALSE;
RECT Rect;
SetRect(&Rect,137,89,20,20);
MapDialogRect(&Rect);
InvalidateRect(&Rect);
}
void CClassInfoDlg::OnSelchangeIdCombo()
{
int nIndex = m_IDList.GetCurSel();
if(m_CurSelIndex == nIndex)
return;
else
m_CurSelIndex = nIndex;
m_ClassList.SetCurSel(m_CurSelIndex);
m_clrColor = ClassInfoArray.GetAt(m_CurSelIndex)->m_clrColor;
m_bChange = TRUE;
SetDlgItemInt(IDC_RED,GetRValue(m_clrColor));
SetDlgItemInt(IDC_GREEN,GetGValue(m_clrColor));
SetDlgItemInt(IDC_BLUE,GetBValue(m_clrColor));
m_bChange = FALSE;
RECT Rect;
SetRect(&Rect,137,89,20,20);
MapDialogRect(&Rect);
InvalidateRect(&Rect);
}
void CClassInfoDlg::OnApply()
{
pView->SendMessage(WM_PAINT);
}
void CClassInfoDlg::OnEditchangeClasslistCombo()
{
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -