www.pudn.com > wi.zip > TmpOcxCtl.cpp, change:2003-06-11,size:6107b


// TmpOcxCtl.cpp : Implementation of the CTmpOcxCtrl ActiveX Control class. 
 
#include "stdafx.h" 
#include "TmpOcx.h" 
#include "TmpOcxCtl.h" 
#include "TmpOcxPpg.h" 
 
 
#ifdef _DEBUG 
#define new DEBUG_NEW 
#undef THIS_FILE 
static char THIS_FILE[] = __FILE__; 
#endif 
 
 
IMPLEMENT_DYNCREATE(CTmpOcxCtrl, COleControl) 
 
 
///////////////////////////////////////////////////////////////////////////// 
// Message map 
 
BEGIN_MESSAGE_MAP(CTmpOcxCtrl, COleControl) 
	//{{AFX_MSG_MAP(CTmpOcxCtrl) 
	// 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(CTmpOcxCtrl, COleControl) 
	//{{AFX_DISPATCH_MAP(CTmpOcxCtrl) 
	DISP_PROPERTY_EX(CTmpOcxCtrl, "MsgContext", GetMsgContext, SetMsgContext, VT_BSTR) 
	DISP_FUNCTION(CTmpOcxCtrl, "ShowMessage", ShowMessage, VT_EMPTY, VTS_NONE) 
	//}}AFX_DISPATCH_MAP 
	DISP_FUNCTION_ID(CTmpOcxCtrl, "AboutBox", DISPID_ABOUTBOX, AboutBox, VT_EMPTY, VTS_NONE) 
END_DISPATCH_MAP() 
 
 
///////////////////////////////////////////////////////////////////////////// 
// Event map 
 
BEGIN_EVENT_MAP(CTmpOcxCtrl, COleControl) 
	//{{AFX_EVENT_MAP(CTmpOcxCtrl) 
	EVENT_CUSTOM("OnMsgChange", FireOnMsgChange, VTS_NONE) 
	//}}AFX_EVENT_MAP 
END_EVENT_MAP() 
 
 
///////////////////////////////////////////////////////////////////////////// 
// Property pages 
 
// TODO: Add more property pages as needed.  Remember to increase the count! 
BEGIN_PROPPAGEIDS(CTmpOcxCtrl, 1) 
	PROPPAGEID(CTmpOcxPropPage::guid) 
END_PROPPAGEIDS(CTmpOcxCtrl) 
 
 
///////////////////////////////////////////////////////////////////////////// 
// Initialize class factory and guid 
 
IMPLEMENT_OLECREATE_EX(CTmpOcxCtrl, "TMPOCX.TmpOcxCtrl.1", 
	0xd7cfafda, 0x467d, 0x4aa7, 0x8e, 0x5, 0xa5, 0x58, 0x17, 0x81, 0x88, 0xaf) 
 
 
///////////////////////////////////////////////////////////////////////////// 
// Type library ID and version 
 
IMPLEMENT_OLETYPELIB(CTmpOcxCtrl, _tlid, _wVerMajor, _wVerMinor) 
 
 
///////////////////////////////////////////////////////////////////////////// 
// Interface IDs 
 
const IID BASED_CODE IID_DTmpOcx = 
		{ 0xde1716be, 0x9113, 0x4b56, { 0xac, 0xa8, 0x2f, 0xfd, 0xff, 0xa7, 0xbf, 0xf8 } }; 
const IID BASED_CODE IID_DTmpOcxEvents = 
		{ 0x59981df3, 0x9674, 0x45ca, { 0x94, 0xf8, 0x29, 0x5e, 0x6c, 0x1d, 0x5a, 0x9f } }; 
 
 
///////////////////////////////////////////////////////////////////////////// 
// Control type information 
 
static const DWORD BASED_CODE _dwTmpOcxOleMisc = 
	OLEMISC_ACTIVATEWHENVISIBLE | 
	OLEMISC_SETCLIENTSITEFIRST | 
	OLEMISC_INSIDEOUT | 
	OLEMISC_CANTLINKINSIDE | 
	OLEMISC_RECOMPOSEONRESIZE; 
 
IMPLEMENT_OLECTLTYPE(CTmpOcxCtrl, IDS_TMPOCX, _dwTmpOcxOleMisc) 
 
 
///////////////////////////////////////////////////////////////////////////// 
// CTmpOcxCtrl::CTmpOcxCtrlFactory::UpdateRegistry - 
// Adds or removes system registry entries for CTmpOcxCtrl 
 
BOOL CTmpOcxCtrl::CTmpOcxCtrlFactory::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_TMPOCX, 
			IDB_TMPOCX, 
			afxRegApartmentThreading, 
			_dwTmpOcxOleMisc, 
			_tlid, 
			_wVerMajor, 
			_wVerMinor); 
	else 
		return AfxOleUnregisterClass(m_clsid, m_lpszProgID); 
} 
 
 
///////////////////////////////////////////////////////////////////////////// 
// CTmpOcxCtrl::CTmpOcxCtrl - Constructor 
 
CTmpOcxCtrl::CTmpOcxCtrl() 
{ 
	InitializeIIDs(&IID_DTmpOcx, &IID_DTmpOcxEvents); 
 
	// TODO: Initialize your control's instance data here. 
} 
 
 
///////////////////////////////////////////////////////////////////////////// 
// CTmpOcxCtrl::~CTmpOcxCtrl - Destructor 
 
CTmpOcxCtrl::~CTmpOcxCtrl() 
{ 
	// TODO: Cleanup your control's instance data here. 
} 
 
 
///////////////////////////////////////////////////////////////////////////// 
// CTmpOcxCtrl::OnDraw - Drawing function 
 
void CTmpOcxCtrl::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); 
} 
 
 
///////////////////////////////////////////////////////////////////////////// 
// CTmpOcxCtrl::DoPropExchange - Persistence support 
 
void CTmpOcxCtrl::DoPropExchange(CPropExchange* pPX) 
{ 
	ExchangeVersion(pPX, MAKELONG(_wVerMinor, _wVerMajor)); 
	COleControl::DoPropExchange(pPX); 
 
	PX_String(pPX,"MsgContext",m_MsgContext,"ӭʹôAcitvexǺ"); 
 
} 
 
 
///////////////////////////////////////////////////////////////////////////// 
// CTmpOcxCtrl::OnResetState - Reset control to default state 
 
void CTmpOcxCtrl::OnResetState() 
{ 
	COleControl::OnResetState();  // Resets defaults found in DoPropExchange 
 
	// TODO: Reset any other control state here. 
} 
 
 
///////////////////////////////////////////////////////////////////////////// 
// CTmpOcxCtrl::AboutBox - Display an "About" box to the user 
 
void CTmpOcxCtrl::AboutBox() 
{ 
	CDialog dlgAbout(IDD_ABOUTBOX_TMPOCX); 
	dlgAbout.DoModal(); 
} 
 
 
///////////////////////////////////////////////////////////////////////////// 
// CTmpOcxCtrl message handlers 
 
 
void CTmpOcxCtrl::ShowMessage()  
{ 
   AfxMessageBox(m_MsgContext); 
} 
 
 
BSTR CTmpOcxCtrl::GetMsgContext()  
{ 
    return m_MsgContext.AllocSysString(); 
} 
 
void CTmpOcxCtrl::SetMsgContext(LPCTSTR lpszNewValue)  
{ 
	if (m_MsgContext.Compare(lpszNewValue) != 0 ) 
	{ 
		m_MsgContext = lpszNewValue; 
		FireOnMsgChange(); 
		SetModifiedFlag(); 
	} 
}