// This is a part of the Microsoft Foundation Classes C++ library.
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// This source code is only intended as a supplement to the
// Microsoft Foundation Classes Reference and related
// electronic documentation provided with the library.
// See these sources for detailed information regarding the
// Microsoft Foundation Classes product.
#include "stdafx.h"
#include "NewControls.h"
#include "CustomProperties.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
////////////////////////////////////////////////////////////////////////////////
// CCheckBoxProp class
CCheckBoxProp::CCheckBoxProp(const CString& strName, BOOL bCheck, LPCTSTR lpszDescr, DWORD dwData) :
CMFCPropertyGridProperty(strName, COleVariant((long)bCheck), lpszDescr, dwData)
{
m_rectCheck.SetRectEmpty();
}
void CCheckBoxProp::OnDrawName(CDC* pDC, CRect rect)
{
m_rectCheck = rect;
m_rectCheck.DeflateRect(1, 1);
m_rectCheck.right = m_rectCheck.left + m_rectCheck.Height();
rect.left = m_rectCheck.right + 1;
CMFCPropertyGridProperty::OnDrawName(pDC, rect);
OnDrawCheckBox(pDC, m_rectCheck, (m_varValue.boolVal));
}
void CCheckBoxProp::OnClickName(CPoint point)
{
if (m_bEnabled && m_rectCheck.PtInRect(point))
{
m_varValue.boolVal = !(m_varValue.boolVal);
m_pWndList->InvalidateRect(m_rectCheck);
}
}
BOOL CCheckBoxProp::OnDblClk(CPoint point)
{
if (m_bEnabled && m_rectCheck.PtInRect(point))
{
return TRUE;
}
m_varValue.boolVal = !(m_varValue.boolVal);
m_pWndList->InvalidateRect(m_rectCheck);
return TRUE;
}
void CCheckBoxProp::OnDrawCheckBox(CDC * pDC, CRect rect, BOOL bChecked)
{
COLORREF clrTextOld = pDC->GetTextColor();
CMFCVisualManager::GetInstance()->OnDrawCheckBox(pDC, rect, FALSE, bChecked, m_bEnabled);
pDC->SetTextColor(clrTextOld);
}
BOOL CCheckBoxProp::PushChar(UINT nChar)
{
if (nChar == VK_SPACE)
{
OnDblClk(CPoint(-1, -1));
}
return TRUE;
}
////////////////////////////////////////////////////////////////////////////////
// CPasswordProp class
const TCHAR cPassword = _T('*');
CPasswordProp::CPasswordProp(const CString& strName, const CString& strPassword, LPCTSTR lpszDescr, DWORD dwData)
: CMFCPropertyGridProperty(strName, (LPCTSTR) strPassword, lpszDescr, dwData)
{
}
CWnd* CPasswordProp::CreateInPlaceEdit(CRect rectEdit, BOOL& bDefaultFormat)
{
CEdit* pWndEdit = new CEdit;
DWORD dwStyle = WS_VISIBLE | WS_CHILD | ES_AUTOHSCROLL | ES_PASSWORD;
if (!m_bEnabled || !m_bAllowEdit)
{
dwStyle |= ES_READONLY;
}
pWndEdit->Create(dwStyle, rectEdit, m_pWndList, AFX_PROPLIST_ID_INPLACE);
pWndEdit->SetPasswordChar(cPassword);
bDefaultFormat = TRUE;
return pWndEdit;
}
CString CPasswordProp::FormatProperty()
{
CString strVal = (LPCTSTR)(_bstr_t)m_varValue;
for (int i = 0; i < strVal.GetLength(); i++)
{
strVal.SetAt(i, cPassword);
}
return strVal;
}
/////////////////////////////////////////////////////////////////////////////
// CPropSliderCtrl
CPropSliderCtrl::CPropSliderCtrl(CSliderProp* pProp, COLORREF clrBack)
{
m_clrBack = clrBack;
m_brBackground.CreateSolidBrush(m_clrBack);
m_pProp = pProp;
}
CPropSliderCtrl::~CPropSliderCtrl()
{
}
BEGIN_MESSAGE_MAP(CPropSliderCtrl, CSliderCtrl)
//{{AFX_MSG_MAP(CPropSliderCtrl)
ON_WM_CTLCOLOR_REFLECT()
ON_WM_HSCROLL_REFLECT()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CPropSliderCtrl message handlers
HBRUSH CPropSliderCtrl::CtlColor(CDC* pDC, UINT /*nCtlColor*/)
{
pDC->SetBkColor(m_clrBack);
return m_brBackground;
}
void CPropSliderCtrl::HScroll(UINT /*nSBCode*/, UINT /*nPos*/)
{
ASSERT_VALID(m_pProp);
m_pProp->OnUpdateValue();
m_pProp->Redraw();
}
////////////////////////////////////////////////////////////////////////////////
// CSliderProp class
CSliderProp::CSliderProp(const CString& strName, long nValue, LPCTSTR lpszDescr, DWORD dwData) :
CMFCPropertyGridProperty(strName, nValue, lpszDescr, dwData)
{
}
CWnd* CSliderProp::CreateInPlaceEdit(CRect rectEdit, BOOL& bDefaultFormat)
{
CPropSliderCtrl* pWndSlider = new CPropSliderCtrl(this, m_pWndList->GetBkColor());
rectEdit.left += rectEdit.Height() + 5;
pWndSlider->Create(WS_VISIBLE | WS_CHILD, rectEdit, m_pWndList, AFX_PROPLIST_ID_INPLACE);
pWndSlider->SetPos(m_varValue.lVal);
bDefaultFormat = TRUE;
return pWndSlider;
}
BOOL CSliderProp::OnUpdateValue()
{
ASSERT_VALID(this);
ASSERT_VALID(m_pWndInPlace);
ASSERT_VALID(m_pWndList);
ASSERT(::IsWindow(m_pWndInPlace->GetSafeHwnd()));
long lCurrValue = m_varValue.lVal;
CSliderCtrl* pSlider = (CSliderCtrl*) m_pWndInPlace;
m_varValue = (long) pSlider->GetPos();
if (lCurrValue != m_varValue.lVal)
{
m_pWndList->OnPropertyChanged(this);
}
return TRUE;
}
////////////////////////////////////////////////////////////////////////////////
// CBoundedNumberPairProp class
CBoundedNumberPairProp::CBoundedNumberPairProp(const CString& strGroupName, int nMinValue1, int nMaxValue1, int nMinValue2, int nMaxValue2, DWORD_PTR dwData, BOOL bIsValueList) :
CMFCPropertyGridProperty(strGroupName, dwData, bIsValueList)
{
m_nMinValue1 = nMinValue1;
m_nMaxValue1 = nMaxValue1;
m_nMinValue2 = nMinValue2;
m_nMaxValue2 = nMaxValue2;
}
BOOL CBoundedNumberPairProp::OnUpdateValue()
{
ASSERT_VALID(this);
ASSERT_VALID(m_pWndInPlace);
ASSERT_VALID(m_pWndList);
ASSERT(::IsWindow(m_pWndInPlace->GetSafeHwnd()));
CString strText;
m_pWndInPlace->GetWindowText(strText);
BOOL bIsChanged = FormatProperty() != strText;
if (bIsChanged)
{
CString strDelimeter(_T(","));
for (int i = 0; !strText.IsEmpty() && i < GetSubItemsCount(); i++)
{
CString strItem = strText.SpanExcluding(strDelimeter);
if (strItem.GetLength() + 1 > strText.GetLength())
{
strText.Empty();
}
else
{
strText = strText.Mid(strItem.GetLength() + 1);
}
strItem.TrimLeft();
strItem.TrimRight();
int nItem = _ttoi(strItem);
if ((i == 0) && ((nItem < m_nMinValue1) || (nItem > m_nMaxValue1)))
{
static BOOL bRecursedHere = FALSE;
if (bRecursedHere)
return TRUE;
bRecursedHere = TRUE;
CString strMessage;
strMessage.Format(_T("Height value must be between %d and %d."), m_nMinValue1, m_nMaxValue1);
AfxMessageBox(strMessage);
bRecursedHere = FALSE;
return FALSE;
}
else if ((i == 1) && ((nItem < m_nMinValue2) || (nItem > m_nMaxValue2)))
{
static BOOL bRecursedHere = FALSE;
if (bRecursedHere)
return TRUE;
bRecursedHere = TRUE;
CString strMessage;
strMessage.Format(_T("Width value must be between %d and %d."), m_nMinValue2, m_nMaxValue2);
AfxMessageBox(strMessage);
bRecursedHere = FALSE;
return FALSE;
}
}
return CMFCPropertyGridProperty::OnUpdateValue();
}
return TRUE;
}
////////////////////////////////////////////////////////////////////////////////
// CBoundedNumberSubProp class
CBoundedNumberSubProp::CBoundedNumberSubProp(const CString& strName, const COleVariant& varValue, int nMinValue, int nMaxValue, LPCTSTR lpszDescr) :
CMFCPropertyGridProperty(strName, varValue, lpszDescr)
{
m_nMinValue = nMinValue;
m_nMaxValue = nMaxValue;
}
BOOL CBoundedNumberSubProp::OnUpdateValue()
{
ASSERT_VALID(this);
ASSERT_VALID(m_pWndInPlace);
ASSERT_VALID(m_pWndList);
ASSERT(::IsWindow(m_pWndInPlace->GetSafeHwnd()));
BOOL bRet = TRUE;
CString strText;
m_pWndInPlace->GetWindowText(strText);
BOOL bIsChanged = FormatProperty() != strText;
if (bIsChanged)
{
int nItem = _ttoi(strText);
if ((nItem < m_nMinValue) || (nItem > m_nMaxValue))
{
static BOOL bRecursedHere = FALSE;
if (bRecur
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
MFC 基本常用控件重绘 (103个子文件)
NewControls.aps 171KB
back.bmp 221KB
icons32.bmp 24KB
propicons.bmp 8KB
icons.bmp 7KB
globe.bmp 3KB
button32.bmp 2KB
button32hot.bmp 2KB
buttons.bmp 1KB
image.bmp 1KB
radio_on.bmp 1KB
radio_of.bmp 1KB
btn1_hot.bmp 1KB
btn1.bmp 1KB
stop.bmp 1KB
stop_hot.bmp 1KB
play_hot.bmp 1KB
checkno.bmp 1KB
play.bmp 1KB
bitmap1.bmp 1KB
checkno32.bmp 1KB
radio_of32.bmp 1KB
radio_on32.bmp 1KB
check32.bmp 1KB
test_bit.bmp 406B
toolbar1.bmp 358B
CustomProperties.cpp 17KB
Page5.cpp 13KB
Page1.cpp 8KB
Page2.cpp 6KB
Page3.cpp 4KB
Page4.cpp 4KB
NewControlsPropSheet.cpp 3KB
NewControls.cpp 2KB
Page6.cpp 2KB
stdafx.cpp 207B
Btn.cur 766B
mt.dep 67B
mt.dep 67B
NewControls.exe 6.73MB
NewControls.exe 365KB
Resource.h 6KB
CustomProperties.h 5KB
Page5.h 2KB
Page3.h 2KB
Page1.h 2KB
stdafx.h 2KB
NewControls.h 1KB
Page2.h 1KB
targetver.h 1KB
NewControlsPropSheet.h 1KB
Page4.h 1KB
Page6.h 1KB
BuildLog.htm 14KB
BuildLog.htm 13KB
ReadMe.htm 8KB
NewControls.ico 66KB
vc90.idb 1.9MB
vc90.idb 1.89MB
NewControls.ilk 13.31MB
NewControls.ilk 2.1MB
NewControls.exe.embed.manifest 1KB
NewControls.exe.intermediate.manifest 1KB
NewControls.exe.embed.manifest 682B
NewControls.exe.intermediate.manifest 640B
NewControls.ncb 16.7MB
stdafx.obj 654KB
stdafx.obj 614KB
CustomProperties.obj 280KB
CustomProperties.obj 216KB
Page5.obj 160KB
Page5.obj 120KB
Page3.obj 114KB
Page2.obj 86KB
Page1.obj 82KB
Page3.obj 77KB
NewControlsPropSheet.obj 66KB
Page4.obj 65KB
Page6.obj 61KB
Page2.obj 54KB
Page1.obj 54KB
NewControls.obj 39KB
NewControls.obj 38KB
Page4.obj 38KB
NewControlsPropSheet.obj 37KB
Page6.obj 32KB
NewControls.pch 41.5MB
NewControls.pch 41.31MB
NewControls.pdb 22.5MB
NewControls.pdb 5.35MB
vc90.pdb 3.5MB
vc90.pdb 3.47MB
NewControls.rc 19KB
NewControls.rc2 404B
NewControls.res 1.13MB
NewControls.res 142KB
NewControls.exe.embed.manifest.res 1KB
NewControls.exe.embed.manifest.res 748B
NewControls.sln 4KB
NewControls.suo 12KB
共 103 条
- 1
- 2
资源评论
xuDylan
- 粉丝: 3
- 资源: 35
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功