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

📄 sam_editwindowctl.cpp

📁 制作VC控件教程
💻 CPP
字号:
// Sam_editwindowCtl.cpp : Implementation of the CSam_editwindowCtrl ActiveX Control class.

#include "stdafx.h"
#include "sam_21.h"
#include "Sam_editwindowCtl.h"
#include "Sam_editwindowPpg.h"


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


IMPLEMENT_DYNCREATE(CSam_editwindowCtrl, COleControl)


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

BEGIN_MESSAGE_MAP(CSam_editwindowCtrl, COleControl)
	//{{AFX_MSG_MAP(CSam_editwindowCtrl)
	// 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_MESSAGE(OCM_COMMAND, OnOcmCommand)
	ON_OLEVERB(AFX_IDS_VERB_PROPERTIES, OnProperties)
END_MESSAGE_MAP()


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

BEGIN_DISPATCH_MAP(CSam_editwindowCtrl, COleControl)
	//{{AFX_DISPATCH_MAP(CSam_editwindowCtrl)
	// NOTE - ClassWizard will add and remove dispatch map entries
	//    DO NOT EDIT what you see in these blocks of generated code !
	//}}AFX_DISPATCH_MAP
	DISP_FUNCTION_ID(CSam_editwindowCtrl, "AboutBox", DISPID_ABOUTBOX, AboutBox, VT_EMPTY, VTS_NONE)
END_DISPATCH_MAP()


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

BEGIN_EVENT_MAP(CSam_editwindowCtrl, COleControl)
	//{{AFX_EVENT_MAP(CSam_editwindowCtrl)
	// 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(CSam_editwindowCtrl, 1)
	PROPPAGEID(CSam_editwindowPropPage::guid)
END_PROPPAGEIDS(CSam_editwindowCtrl)


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

IMPLEMENT_OLECREATE_EX(CSam_editwindowCtrl, "SAM21.SameditwindowCtrl.1",
	0x58c72a51, 0xd633, 0x11d3, 0x9b, 0x30, 0x52, 0x54, 0x4c, 0x39, 0x3a, 0x8c)


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

IMPLEMENT_OLETYPELIB(CSam_editwindowCtrl, _tlid, _wVerMajor, _wVerMinor)


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

const IID BASED_CODE IID_DSam_editwindow =
		{ 0x58c72a4f, 0xd633, 0x11d3, { 0x9b, 0x30, 0x52, 0x54, 0x4c, 0x39, 0x3a, 0x8c } };
const IID BASED_CODE IID_DSam_editwindowEvents =
		{ 0x58c72a50, 0xd633, 0x11d3, { 0x9b, 0x30, 0x52, 0x54, 0x4c, 0x39, 0x3a, 0x8c } };


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

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

IMPLEMENT_OLECTLTYPE(CSam_editwindowCtrl, IDS_SAM_EDITWINDOW, _dwSam_editwindowOleMisc)


/////////////////////////////////////////////////////////////////////////////
// CSam_editwindowCtrl::CSam_editwindowCtrlFactory::UpdateRegistry -
// Adds or removes system registry entries for CSam_editwindowCtrl

BOOL CSam_editwindowCtrl::CSam_editwindowCtrlFactory::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_SAM_EDITWINDOW,
			IDB_SAM_EDITWINDOW,
			afxRegApartmentThreading,
			_dwSam_editwindowOleMisc,
			_tlid,
			_wVerMajor,
			_wVerMinor);
	else
		return AfxOleUnregisterClass(m_clsid, m_lpszProgID);
}


/////////////////////////////////////////////////////////////////////////////
// CSam_editwindowCtrl::CSam_editwindowCtrl - Constructor

CSam_editwindowCtrl::CSam_editwindowCtrl()
{
	InitializeIIDs(&IID_DSam_editwindow, &IID_DSam_editwindowEvents);

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


/////////////////////////////////////////////////////////////////////////////
// CSam_editwindowCtrl::~CSam_editwindowCtrl - Destructor

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


/////////////////////////////////////////////////////////////////////////////
// CSam_editwindowCtrl::OnDraw - Drawing function

void CSam_editwindowCtrl::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);
}


/////////////////////////////////////////////////////////////////////////////
// CSam_editwindowCtrl::DoPropExchange - Persistence support

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

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

}


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

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

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


/////////////////////////////////////////////////////////////////////////////
// CSam_editwindowCtrl::AboutBox - Display an "About" box to the user

void CSam_editwindowCtrl::AboutBox()
{
	CDialog dlgAbout(IDD_ABOUTBOX_SAM_EDITWINDOW);
	dlgAbout.DoModal();
}
/////////////////////////////////////////////////////////////////////////////
// CSam_windowCtrl::PreCreateWindow - Modify parameters for CreateWindowEx

BOOL CSam_editwindowCtrl::PreCreateWindow(CREATESTRUCT& cs)
{
	cs.lpszClass = _T("EDIT");
	return COleControl::PreCreateWindow(cs);
}


/////////////////////////////////////////////////////////////////////////////
// CSam_windowCtrl::IsSubclassedControl - This is a subclassed control

BOOL CSam_editwindowCtrl::IsSubclassedControl()
{
	return TRUE;
}


/////////////////////////////////////////////////////////////////////////////
// CSam_windowCtrl::OnOcmCommand - Handle command messages

LRESULT CSam_editwindowCtrl::OnOcmCommand(WPARAM wParam, LPARAM lParam)
{
#ifdef _WIN32
	WORD wNotifyCode = HIWORD(wParam);
#else
	WORD wNotifyCode = HIWORD(lParam);
#endif

	// TODO: Switch on wNotifyCode here.

	return 0;
}




/////////////////////////////////////////////////////////////////////////////
// CSam_editwindowCtrl message handlers

⌨️ 快捷键说明

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