Визуальное программирование и MFC

       

NameCtl.cpp


// NameCtl.cpp : Implementation of the CNameCtrl ActiveX Control class.   #include "stdafx.h" #include "name.h" #include "NameCtl.h" #include "NamePpg.h"   #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif   IMPLEMENT_DYNCREATE(CNameCtrl, COleControl)   ///////////////////////////////////////////////////////////////////////////// // Message map   BEGIN_MESSAGE_MAP(CNameCtrl, COleControl) //{{AFX_MSG_MAP(CNameCtrl) // 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(CNameCtrl, COleControl) //{{AFX_DISPATCH_MAP(CNameCtrl) // 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(CNameCtrl, "AboutBox", DISPID_ABOUTBOX, AboutBox, VT_EMPTY, VTS_NONE) END_DISPATCH_MAP()   ///////////////////////////////////////////////////////////////////////////// // Event map BEGIN_EVENT_MAP(CNameCtrl, COleControl) //{{AFX_EVENT_MAP(CNameCtrl) // 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(CNameCtrl, 1) PROPPAGEID(CNamePropPage::guid) END_PROPPAGEIDS(CNameCtrl)   ///////////////////////////////////////////////////////////////////////////// // Initialize class factory and guid IMPLEMENT_OLECREATE_EX(CNameCtrl, "NAME.NameCtrl.1", 0xb85d087c, 0xf9fa, 0x11d1, 0x95, 0x25, 0, 0x80, 0x48, 0x89, 0x29, 0xd2)   ///////////////////////////////////////////////////////////////////////////// // Type library ID and version IMPLEMENT_OLETYPELIB(CNameCtrl, _tlid, _wVerMajor, _wVerMinor)   ///////////////////////////////////////////////////////////////////////////// // Interface IDs   const IID BASED_CODE IID_DName = { 0xec72d07b, 0xfabf, 0x11d1, { 0x95, 0x25, 0, 0x80, 0x48, 0x89, 0x29, 0xd2 } }; const IID BASED_CODE IID_DNameEvents = { 0xec72d07c, 0xfabf, 0x11d1, { 0x95, 0x25, 0, 0x80, 0x48, 0x89, 0x29, 0xd2 } };   ///////////////////////////////////////////////////////////////////////////// // Control type information static const DWORD BASED_CODE _dwNameOleMisc = OLEMISC_ACTIVATEWHENVISIBLE | OLEMISC_SETCLIENTSITEFIRST | OLEMISC_INSIDEOUT | OLEMISC_CANTLINKINSIDE | OLEMISC_RECOMPOSEONRESIZE;   IMPLEMENT_OLECTLTYPE(CNameCtrl, IDS_NAME, _dwNameOleMisc)   ///////////////////////////////////////////////////////////////////////////// // CNameCtrl::CNameCtrlFactory::UpdateRegistry - // Adds or removes system registry entries for CNameCtrl   BOOL CNameCtrl::CNameCtrlFactory::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_NAME, IDB_NAME, afxRegApartmentThreading, _dwNameOleMisc, _tlid, _wVerMajor, _wVerMinor); else return AfxOleUnregisterClass(m_clsid, m_lpszProgID); }   ///////////////////////////////////////////////////////////////////////////// // CNameCtrl::CNameCtrl - Constructor   CNameCtrl::CNameCtrl() { InitializeIIDs(&IID_DName, &IID_DNameEvents);   // TODO: Initialize your control's instance data here. }   ///////////////////////////////////////////////////////////////////////////// // CNameCtrl::~CNameCtrl - Destructor   CNameCtrl::~CNameCtrl() { // TODO: Cleanup your control's instance data here. }   ///////////////////////////////////////////////////////////////////////////// // CNameCtrl::OnDraw - Drawing function   void CNameCtrl::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); }   ///////////////////////////////////////////////////////////////////////////// // CNameCtrl::DoPropExchange - Persistence support   void CNameCtrl::DoPropExchange(CPropExchange* pPX) { ExchangeVersion(pPX, MAKELONG(_wVerMinor, _wVerMajor)); COleControl::DoPropExchange(pPX);   // TODO: Call PX_ functions for each persistent custom property.   }   ///////////////////////////////////////////////////////////////////////////// // CNameCtrl::OnResetState - Reset control to default state   void CNameCtrl::OnResetState() { COleControl::OnResetState(); // Resets defaults found in DoPropExchange   // TODO: Reset any other control state here. }   ///////////////////////////////////////////////////////////////////////////// // CNameCtrl::AboutBox - Display an "About" box to the user   void CNameCtrl::AboutBox() { CDialog dlgAbout(IDD_ABOUTBOX_NAME); dlgAbout.DoModal(); }   ///////////////////////////////////////////////////////////////////////////// // CNameCtrl message handlers


Содержание раздела