⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ceeditctl.cpp

📁 一个wince下控件
💻 CPP
字号:
// CEEditCtl.cpp : Implementation of the CCEEditCtrl ActiveX Control class.

#include "stdafx.h"
#include "CEEdit.h"
#include "CEEditCtl.h"
#include "CEEditPpg.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

#define afxRegBothThreading 0x0004

IMPLEMENT_DYNCREATE(CCEEditCtrl, COleControl)


/////////////////////////////////////////////////////////////////////////////
// Message map

BEGIN_MESSAGE_MAP(CCEEditCtrl, COleControl)
	//{{AFX_MSG_MAP(CCEEditCtrl)
	// NOTE - ClassWizard will add and remove message map entries
	//    DO NOT EDIT what you see in these blocks of generated code !
	//}}AFX_MSG_MAP
	ON_OLEVERB(AFX_IDS_VERB_PROPERTIES, OnProperties)
END_MESSAGE_MAP()


/////////////////////////////////////////////////////////////////////////////
// Dispatch map

BEGIN_DISPATCH_MAP(CCEEditCtrl, COleControl)
	//{{AFX_DISPATCH_MAP(CCEEditCtrl)
	DISP_PROPERTY_EX(CCEEditCtrl, "FontFaceName", GetFontFaceName, SetFontFaceName, VT_BSTR)
	DISP_PROPERTY_EX(CCEEditCtrl, "FontWidth", GetFontWidth, SetFontWidth, VT_I4)
	DISP_PROPERTY_EX(CCEEditCtrl, "FontHeight", GetFontHeight, SetFontHeight, VT_I4)
	DISP_PROPERTY_EX(CCEEditCtrl, "FontEscapement", GetFontEscapement, SetFontEscapement, VT_I4)
	DISP_PROPERTY_EX(CCEEditCtrl, "FontOrientation", GetFontOrientation, SetFontOrientation, VT_I4)
	DISP_PROPERTY_EX(CCEEditCtrl, "FontItalic", GetFontItalic, SetFontItalic, VT_I4)
	DISP_PROPERTY_EX(CCEEditCtrl, "FontUnderline", GetFontUnderline, SetFontUnderline, VT_I4)
	DISP_PROPERTY_EX(CCEEditCtrl, "FontStrikeOut", GetFontStrikeOut, SetFontStrikeOut, VT_I4)
	DISP_PROPERTY_EX(CCEEditCtrl, "FontCharSet", GetFontCharSet, SetFontCharSet, VT_I4)
	DISP_PROPERTY_EX(CCEEditCtrl, "FontOutPrecision", GetFontOutPrecision, SetFontOutPrecision, VT_I4)
	DISP_PROPERTY_EX(CCEEditCtrl, "FontQuality", GetFontQuality, SetFontQuality, VT_I4)
	DISP_PROPERTY_EX(CCEEditCtrl, "FontPitchAndFamily", GetFontPitchAndFamily, SetFontPitchAndFamily, VT_I4)
	DISP_PROPERTY_EX(CCEEditCtrl, "FontWeight", GetFontWeight, SetFontWeight, VT_I4)
	DISP_PROPERTY_EX(CCEEditCtrl, "FontClipPrecision", GetFontClipPrecision, SetFontClipPrecision, VT_I4)
	DISP_PROPERTY_EX(CCEEditCtrl, "FrameColor", GetFrameColor, SetFrameColor, VT_COLOR)
	DISP_PROPERTY_EX(CCEEditCtrl, "FrameStyle", GetFrameStyle, SetFrameStyle, VT_I4)
	DISP_PROPERTY_EX(CCEEditCtrl, "Model", GetModel, SetModel, VT_I4)
	DISP_PROPERTY_EX(CCEEditCtrl, "PictureFileName", GetPictureFileName, SetPictureFileName, VT_BSTR)
	DISP_PROPERTY_EX(CCEEditCtrl, "BackStyle", GetBackStyle, SetBackStyle, VT_I4)
	DISP_PROPERTY_EX(CCEEditCtrl, "TransparentColor", GetTransparentColor, SetTransparentColor, VT_COLOR)
	DISP_PROPERTY_EX(CCEEditCtrl, "BackColor", GetBackColor, SetBackColor, VT_COLOR)
	DISP_PROPERTY_EX(CCEEditCtrl, "Caption", GetCaption, SetCaption, VT_BSTR)
	DISP_PROPERTY_EX(CCEEditCtrl, "Enabled", GetEnabled, SetEnabled, VT_BOOL)
	DISP_PROPERTY_EX(CCEEditCtrl, "ForeColor", GetForeColor, SetForeColor, VT_COLOR)
	DISP_PROPERTY_EX(CCEEditCtrl, "HWnd", GetHWnd, SetHWnd, VT_HANDLE)
	//}}AFX_DISPATCH_MAP
END_DISPATCH_MAP()


/////////////////////////////////////////////////////////////////////////////
// Event map

BEGIN_EVENT_MAP(CCEEditCtrl, COleControl)
	//{{AFX_EVENT_MAP(CCEEditCtrl)
	// NOTE - ClassWizard will add and remove event map entries
	//    DO NOT EDIT what you see in these blocks of generated code !
	//}}AFX_EVENT_MAP
END_EVENT_MAP()


/////////////////////////////////////////////////////////////////////////////
// Property pages

// TODO: Add more property pages as needed.  Remember to increase the count!
BEGIN_PROPPAGEIDS(CCEEditCtrl, 1)
	PROPPAGEID(CCEEditPropPage::guid)
END_PROPPAGEIDS(CCEEditCtrl)


/////////////////////////////////////////////////////////////////////////////
// Initialize class factory and guid

IMPLEMENT_OLECREATE_EX(CCEEditCtrl, "CEEDIT.CEEditCtrl.1",
	0xb7f9cb96, 0x4dee, 0x4f13, 0x96, 0xff, 0xe4, 0xd2, 0xf0, 0x21, 0xf6, 0xbb)


/////////////////////////////////////////////////////////////////////////////
// Type library ID and version

IMPLEMENT_OLETYPELIB(CCEEditCtrl, _tlid, _wVerMajor, _wVerMinor)


/////////////////////////////////////////////////////////////////////////////
// Interface IDs

const IID BASED_CODE IID_DCEEdit =
		{ 0xbaea19ca, 0x38ed, 0x44c5, { 0xab, 0x76, 0x9f, 0x25, 0xf1, 0xe0, 0x45, 0xde } };
const IID BASED_CODE IID_DCEEditEvents =
		{ 0x2e906f3f, 0x3ec0, 0x4109, { 0xa2, 0xf4, 0xf3, 0x39, 0xe0, 0xc5, 0xfc, 0xf7 } };


/////////////////////////////////////////////////////////////////////////////
// Control type information

static const DWORD BASED_CODE _dwCEEditOleMisc =
	OLEMISC_ACTIVATEWHENVISIBLE |
	OLEMISC_SETCLIENTSITEFIRST |
	OLEMISC_INSIDEOUT |
	OLEMISC_CANTLINKINSIDE |
	OLEMISC_RECOMPOSEONRESIZE;

IMPLEMENT_OLECTLTYPE(CCEEditCtrl, IDS_CEEDIT, _dwCEEditOleMisc)


/////////////////////////////////////////////////////////////////////////////
// CCEEditCtrl::CCEEditCtrlFactory::UpdateRegistry -
// Adds or removes system registry entries for CCEEditCtrl

BOOL CCEEditCtrl::CCEEditCtrlFactory::UpdateRegistry(BOOL bRegister)
{
	// TODO: Verify that your control follows apartment-model threading rules.
	// Refer to MFC TechNote 64 for more information.
	// If your control does not conform to the apartment-model rules, then
	// you must modify the code below, changing the 6th parameter from
	// afxRegApartmentThreading to 0.

	if (bRegister)
		return AfxOleRegisterControlClass(
			AfxGetInstanceHandle(),
			m_clsid,
			m_lpszProgID,
			IDS_CEEDIT,
			IDB_CEEDIT,
			afxRegBothThreading,
			_dwCEEditOleMisc,
			_tlid,
			_wVerMajor,
			_wVerMinor);
	else
		return AfxOleUnregisterClass(m_clsid, m_lpszProgID);
}


/////////////////////////////////////////////////////////////////////////////
// CCEEditCtrl::CCEEditCtrl - Constructor

CCEEditCtrl::CCEEditCtrl()
{
	InitializeIIDs(&IID_DCEEdit, &IID_DCEEditEvents);

	// TODO: Initialize your control's instance data here.
}


/////////////////////////////////////////////////////////////////////////////
// CCEEditCtrl::~CCEEditCtrl - Destructor

CCEEditCtrl::~CCEEditCtrl()
{
	// TODO: Cleanup your control's instance data here.
}


/////////////////////////////////////////////////////////////////////////////
// CCEEditCtrl::OnDraw - Drawing function

void CCEEditCtrl::OnDraw(CDC* pdc, const CRect& rcBounds, const CRect& rcInvalid)
{
	// TODO: Replace the following code with your own drawing code.
	//pdc->FillRect(rcBounds, CBrush::FromHandle((HBRUSH)GetStockObject(WHITE_BRUSH)));
	//pdc->Ellipse(rcBounds);
	CBrush brush (TranslateColor (GetBackColor()));
	pdc->FillRect (rcBounds, &brush);
	
	m_edit.m_bkColor=TranslateColor(GetBackColor()); 
	m_edit.m_caption = GetText();
	m_edit.m_foreColor = TranslateColor(GetForeColor());
	
	m_edit.m_rect=rcBounds;
	m_edit.Draw(pdc->m_hDC); 
}


/////////////////////////////////////////////////////////////////////////////
// CCEEditCtrl::DoPropExchange - Persistence support

void CCEEditCtrl::DoPropExchange(CPropExchange* pPX)
{
	ExchangeVersion(pPX, MAKELONG(_wVerMinor, _wVerMajor));
	COleControl::DoPropExchange(pPX);

	// TODO: Call PX_ functions for each persistent custom property.

}


/////////////////////////////////////////////////////////////////////////////
// CCEEditCtrl::OnResetState - Reset control to default state

void CCEEditCtrl::OnResetState()
{
	COleControl::OnResetState();  // Resets defaults found in DoPropExchange

	// TODO: Reset any other control state here.
}


/////////////////////////////////////////////////////////////////////////////
// CCEEditCtrl message handlers

BSTR CCEEditCtrl::GetFontFaceName() 
{
	CString strResult;//=m_edit.lf.lfFaceName;

	return strResult.AllocSysString();
}

void CCEEditCtrl::SetFontFaceName(LPCTSTR lpszNewValue) 
{
	//m_edit.lf.lfFaceName = lpszNewValue;
	//InvalidateControl ();

	SetModifiedFlag();
}

long CCEEditCtrl::GetFontWidth() 
{

	return m_edit.lf.lfWidth;
}

void CCEEditCtrl::SetFontWidth(long nNewValue) 
{
	m_edit.lf.lfWidth = nNewValue;
	InvalidateControl ();

	SetModifiedFlag();
}

long CCEEditCtrl::GetFontHeight() 
{

	return m_edit.lf.lfHeight;
}

void CCEEditCtrl::SetFontHeight(long nNewValue) 
{
	m_edit.lf.lfHeight = nNewValue;
	InvalidateControl ();

	SetModifiedFlag();
}

long CCEEditCtrl::GetFontEscapement() 
{

	return m_edit.lf.lfEscapement;
}

void CCEEditCtrl::SetFontEscapement(long nNewValue) 
{
	m_edit.lf.lfEscapement = nNewValue;
	InvalidateControl ();

	SetModifiedFlag();
}

long CCEEditCtrl::GetFontOrientation() 
{

	return m_edit.lf.lfOrientation;
}

void CCEEditCtrl::SetFontOrientation(long nNewValue) 
{
	m_edit.lf.lfOrientation = nNewValue;
	InvalidateControl ();

	SetModifiedFlag();
}

long CCEEditCtrl::GetFontItalic() 
{

	return m_edit.lf.lfItalic;
}

void CCEEditCtrl::SetFontItalic(long nNewValue) 
{
	m_edit.lf.lfItalic = (BYTE)nNewValue;
	InvalidateControl ();

	SetModifiedFlag();
}

long CCEEditCtrl::GetFontUnderline() 
{

	return m_edit.lf.lfUnderline;
}

void CCEEditCtrl::SetFontUnderline(long nNewValue) 
{
	m_edit.lf.lfUnderline =(BYTE) nNewValue;
	InvalidateControl ();

	SetModifiedFlag();
}

long CCEEditCtrl::GetFontStrikeOut() 
{

	return m_edit.lf.lfStrikeOut;
}

void CCEEditCtrl::SetFontStrikeOut(long nNewValue) 
{
	m_edit.lf.lfStrikeOut =(BYTE) nNewValue;
	InvalidateControl ();

	SetModifiedFlag();
}

long CCEEditCtrl::GetFontCharSet() 
{

	return m_edit.lf.lfCharSet;
}

void CCEEditCtrl::SetFontCharSet(long nNewValue) 
{
	m_edit.lf.lfCharSet =(BYTE) nNewValue;
	InvalidateControl ();

	SetModifiedFlag();
}

long CCEEditCtrl::GetFontOutPrecision() 
{
	// TODO: Add your property handler here

	return m_edit.lf.lfOutPrecision;
}

void CCEEditCtrl::SetFontOutPrecision(long nNewValue) 
{
	m_edit.lf.lfOutPrecision =(BYTE) nNewValue;
	InvalidateControl ();

	SetModifiedFlag();
}

long CCEEditCtrl::GetFontQuality() 
{
	

	return m_edit.lf.lfQuality;
}

void CCEEditCtrl::SetFontQuality(long nNewValue) 
{
	m_edit.lf.lfQuality  =(BYTE) nNewValue;
	InvalidateControl ();

	SetModifiedFlag();
}

long CCEEditCtrl::GetFontPitchAndFamily() 
{
	return m_edit.lf.lfPitchAndFamily;
}

void CCEEditCtrl::SetFontPitchAndFamily(long nNewValue) 
{
	m_edit.lf.lfPitchAndFamily   =(BYTE) nNewValue;
	InvalidateControl ();

	SetModifiedFlag();
}

long CCEEditCtrl::GetFontWeight() 
{
	return m_edit.lf.lfWeight;
}

void CCEEditCtrl::SetFontWeight(long nNewValue) 
{
	m_edit.lf.lfWeight = (BYTE) nNewValue;
	InvalidateControl ();

	SetModifiedFlag();
}

long CCEEditCtrl::GetFontClipPrecision() 
{
	return m_edit.lf.lfClipPrecision;
}

void CCEEditCtrl::SetFontClipPrecision(long nNewValue) 
{
	m_edit.lf.lfClipPrecision = (BYTE) nNewValue;
	InvalidateControl ();

	SetModifiedFlag();
}

OLE_COLOR CCEEditCtrl::GetFrameColor() 
{

	return m_edit.m_frameColor;
}

void CCEEditCtrl::SetFrameColor(OLE_COLOR nNewValue) 
{
	m_edit.m_frameColor = TranslateColor(nNewValue);
	InvalidateControl ();
	SetModifiedFlag();
}

long CCEEditCtrl::GetFrameStyle() 
{
	return m_edit.m_frameStyle;
}

void CCEEditCtrl::SetFrameStyle(long nNewValue) 
{
	m_edit.m_frameStyle = nNewValue;
	InvalidateControl ();
	SetModifiedFlag();
}

long CCEEditCtrl::GetModel() 
{
	return m_edit.m_model;
}

void CCEEditCtrl::SetModel(long nNewValue) 
{
	m_edit.m_model = nNewValue;
	InvalidateControl ();
	SetModifiedFlag();
}

BSTR CCEEditCtrl::GetPictureFileName() 
{
	return m_edit.m_pictureFileName.AllocSysString();
}

void CCEEditCtrl::SetPictureFileName(LPCTSTR lpszNewValue) 
{
	m_edit.m_pictureFileName = lpszNewValue;
	InvalidateControl ();

	SetModifiedFlag();
}

long CCEEditCtrl::GetBackStyle() 
{
	return m_edit.m_bkStyle;
}

void CCEEditCtrl::SetBackStyle(long nNewValue) 
{
	m_edit.m_bkStyle = nNewValue;
	InvalidateControl ();

	SetModifiedFlag();
}

OLE_COLOR CCEEditCtrl::GetTransparentColor() 
{
	// TODO: Add your property handler here

	return m_edit.TransparentColor;
}

void CCEEditCtrl::SetTransparentColor(OLE_COLOR nNewValue) 
{
	
	m_edit.TransparentColor = TranslateColor(nNewValue);
	InvalidateControl ();
	SetModifiedFlag();
}

OLE_COLOR CCEEditCtrl::GetBackColor() 
{
	// TODO: Add your property handler here

	return RGB(0,0,0);
}

void CCEEditCtrl::SetBackColor(OLE_COLOR nNewValue) 
{
	// TODO: Add your property handler here

	SetModifiedFlag();
}

BSTR CCEEditCtrl::GetCaption() 
{
	CString strResult;
	// TODO: Add your property handler here

	return strResult.AllocSysString();
}

void CCEEditCtrl::SetCaption(LPCTSTR lpszNewValue) 
{
	// TODO: Add your property handler here

	SetModifiedFlag();
}

BOOL CCEEditCtrl::GetEnabled() 
{
	// TODO: Add your property handler here

	return TRUE;
}

void CCEEditCtrl::SetEnabled(BOOL bNewValue) 
{
	// TODO: Add your property handler here

	SetModifiedFlag();
}

OLE_COLOR CCEEditCtrl::GetForeColor() 
{
	// TODO: Add your property handler here

	return RGB(0,0,0);
}

void CCEEditCtrl::SetForeColor(OLE_COLOR nNewValue) 
{
	// TODO: Add your property handler here

	SetModifiedFlag();
}

OLE_HANDLE CCEEditCtrl::GetHWnd() 
{
	// TODO: Add your property handler here

	return NULL;
}

void CCEEditCtrl::SetHWnd(OLE_HANDLE nNewValue) 
{
	// TODO: Add your property handler here

	SetModifiedFlag();
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -