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

📄 sam_nowindowctl.cpp

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

#include "stdafx.h"
#include "sam_21.h"
#include "Sam_nowindowCtl.h"
#include "Sam_nowindowPpg.h"


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


IMPLEMENT_DYNCREATE(CSam_nowindowCtrl, COleControl)


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

BEGIN_MESSAGE_MAP(CSam_nowindowCtrl, COleControl)
	//{{AFX_MSG_MAP(CSam_nowindowCtrl)
	// 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(CSam_nowindowCtrl, COleControl)
	//{{AFX_DISPATCH_MAP(CSam_nowindowCtrl)
	DISP_FUNCTION(CSam_nowindowCtrl, "DoCalc", DoCalc, VT_I4, VTS_I4 VTS_I4 VTS_BOOL)
	//}}AFX_DISPATCH_MAP
	DISP_FUNCTION_ID(CSam_nowindowCtrl, "AboutBox", DISPID_ABOUTBOX, AboutBox, VT_EMPTY, VTS_NONE)
END_DISPATCH_MAP()


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

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


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

IMPLEMENT_OLECREATE_EX(CSam_nowindowCtrl, "SAM21.SamnowindowCtrl.1",
	0x58c72a4d, 0xd633, 0x11d3, 0x9b, 0x30, 0x52, 0x54, 0x4c, 0x39, 0x3a, 0x8c)


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

IMPLEMENT_OLETYPELIB(CSam_nowindowCtrl, _tlid, _wVerMajor, _wVerMinor)


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

const IID BASED_CODE IID_DSam_nowindow =
		{ 0x58c72a4b, 0xd633, 0x11d3, { 0x9b, 0x30, 0x52, 0x54, 0x4c, 0x39, 0x3a, 0x8c } };
const IID BASED_CODE IID_DSam_nowindowEvents =
		{ 0x58c72a4c, 0xd633, 0x11d3, { 0x9b, 0x30, 0x52, 0x54, 0x4c, 0x39, 0x3a, 0x8c } };


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

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

IMPLEMENT_OLECTLTYPE(CSam_nowindowCtrl, IDS_SAM_NOWINDOW, _dwSam_nowindowOleMisc)


/////////////////////////////////////////////////////////////////////////////
// CSam_nowindowCtrl::CSam_nowindowCtrlFactory::UpdateRegistry -
// Adds or removes system registry entries for CSam_nowindowCtrl

BOOL CSam_nowindowCtrl::CSam_nowindowCtrlFactory::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_NOWINDOW,
			IDB_SAM_NOWINDOW,
			afxRegApartmentThreading,
			_dwSam_nowindowOleMisc,
			_tlid,
			_wVerMajor,
			_wVerMinor);
	else
		return AfxOleUnregisterClass(m_clsid, m_lpszProgID);
}


/////////////////////////////////////////////////////////////////////////////
// CSam_nowindowCtrl::CSam_nowindowCtrl - Constructor

CSam_nowindowCtrl::CSam_nowindowCtrl()
{
	InitializeIIDs(&IID_DSam_nowindow, &IID_DSam_nowindowEvents);

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


/////////////////////////////////////////////////////////////////////////////
// CSam_nowindowCtrl::~CSam_nowindowCtrl - Destructor

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


/////////////////////////////////////////////////////////////////////////////
// CSam_nowindowCtrl::OnDraw - Drawing function

void CSam_nowindowCtrl::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_nowindowCtrl::DoPropExchange - Persistence support

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

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

}


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

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

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


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

void CSam_nowindowCtrl::AboutBox()
{
	CDialog dlgAbout(IDD_ABOUTBOX_SAM_NOWINDOW);
	dlgAbout.DoModal();
}


/////////////////////////////////////////////////////////////////////////////
// CSam_nowindowCtrl message handlers

long CSam_nowindowCtrl::DoCalc(long iNum1, long iNum2, BOOL fShow) 
{
	long lRet=iNum1+iNum2;
	if(fShow)
	{
		CString szOut;
		szOut.Format("%d + %d = %d",iNum1,iNum2,lRet);
		AfxMessageBox(szOut);
	}
	return lRet;
}

⌨️ 快捷键说明

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